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 |
|---|---|---|---|---|---|---|
PATCH/PUT /xmt/passwords/1 PATCH/PUT /xmt/passwords/1.json | def update
respond_to do |format|
if @xmt_mgr_password.update(xmt_mgr_password_params)
format.html { redirect_to @xmt_mgr_password, notice: 'Password was successfully updated.' }
format.json { render :show, status: :ok, location: @xmt_mgr_password }
else
format.html { render :edit }
format.json { render json: @xmt_mgr_password.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#... | [
"0.7408387",
"0.70272034",
"0.70272034",
"0.67063785",
"0.67063785",
"0.6665449",
"0.66454077",
"0.65690064",
"0.6479495",
"0.64356923",
"0.6426468",
"0.6359935",
"0.6325546",
"0.62310475",
"0.621714",
"0.6212519",
"0.6136773",
"0.6089652",
"0.6089278",
"0.60747576",
"0.60540... | 0.63659203 | 11 |
DELETE /xmt/passwords/1 DELETE /xmt/passwords/1.json | def destroy
@xmt_mgr_password.destroy
respond_to do |format|
format.html { redirect_to xmt_mgr_passwords_url, notice: 'Password was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @password.destroy\n respond_to do |format|\n format.html { redirect_to passwords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @password = Password.find(params[:id])\n @password.destroy\n\n respond_to do |format|\n format.html { redirect_to(... | [
"0.6957941",
"0.65897423",
"0.6563262",
"0.6430731",
"0.6370267",
"0.6335186",
"0.62946725",
"0.6270825",
"0.6246007",
"0.6227741",
"0.6204227",
"0.62003034",
"0.6192137",
"0.6177818",
"0.61706686",
"0.61510676",
"0.6146537",
"0.61357766",
"0.61247206",
"0.61143684",
"0.61059... | 0.6906743 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_xmt_mgr_password
@xmt_mgr_password = Xmt::Password.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 xmt_mgr_password_params
params.fetch(:xmt_mgr_password, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Builds a new FlashHash. It takes the hash for this action's values as an initialization variable. | def initialize(session)
@now = session || Hash.new
@next = Hash.new
super(@now)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(hash = {})\n @flash = hash || {}\n @next = {}\n end",
"def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end",
"def <<(hash)\n @flash.set_flash(hash)\n end",
"def build_hash d... | [
"0.6165743",
"0.57207054",
"0.5585175",
"0.5502401",
"0.53196406",
"0.5290826",
"0.5288859",
"0.5264202",
"0.52311176",
"0.5212452",
"0.5208181",
"0.51622796",
"0.50859666",
"0.5082409",
"0.5058297",
"0.50520194",
"0.5041769",
"0.504003",
"0.5012569",
"0.50021815",
"0.4994369... | 0.0 | -1 |
We assign to the _next_ hash, but retrieve values from the _now_ hash. Freaky, huh? | def []=(key, value)
self.next[key] = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_hash(hash)\n db.get(KEY_PREFIX[:next] + hash)\n end",
"def next_hash(hash)\n db.next_hash(hash)\n end",
"def next_renewal_hashes\n wait_until_bus_section_load\n tables[1].hashes\n end",
"def sweep\n @now.replace(@next)\n @next = Hash.new\n ... | [
"0.7059904",
"0.6687956",
"0.6322856",
"0.6142055",
"0.60069984",
"0.600445",
"0.5968473",
"0.5913247",
"0.5907688",
"0.5834334",
"0.58109826",
"0.57636696",
"0.57391375",
"0.57108396",
"0.56973374",
"0.56973374",
"0.56697404",
"0.5668293",
"0.5660031",
"0.5648943",
"0.564596... | 0.0 | -1 |
Swaps out the current flash for the future flash, then returns it. | def sweep
@now.replace(@next)
@next = Hash.new
@now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sweep\n @flash = @next.dup\n @next.clear\n self\n end",
"def flash\n ActionDispatch::Flash::FlashHash.new\n end",
"def flash_keeper\n flash.keep\n end",
"def flash=(_arg0); end",
"def flash\n session[:flash] = Hashie::Mash.new if session[:flash].nil?\n session[:f... | [
"0.63697284",
"0.6165235",
"0.61100554",
"0.59843886",
"0.58981407",
"0.5830601",
"0.5782021",
"0.5646977",
"0.5633552",
"0.56093574",
"0.55567694",
"0.55559623",
"0.5484103",
"0.5481764",
"0.5448748",
"0.54306054",
"0.54275376",
"0.541627",
"0.5404469",
"0.5404469",
"0.53799... | 0.0 | -1 |
Keep all or one of the current values for next time. | def keep(key=nil)
if key
@next[key] = @now[key]
else
@next.merge!(@now)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sweep\n @now.replace(@next)\n @next = Hash.new\n @now\n end",
"def clear\n @now.clear\n @next.clear\n end",
"def mark_no_longer_current\n update_attributes(ended_at: Time.current)\n end",
"def reset\n @value = nil\n @time = Time.new\n @sum = 0.0\n... | [
"0.6223908",
"0.5814627",
"0.5739707",
"0.5636168",
"0.55779403",
"0.55461496",
"0.55258435",
"0.5496948",
"0.5481607",
"0.547608",
"0.54668945",
"0.546628",
"0.543513",
"0.53933483",
"0.5380957",
"0.53558564",
"0.5312267",
"0.5312267",
"0.5306517",
"0.52741027",
"0.5262368",... | 0.6751085 | 0 |
Tosses any values or one value before next time. | def discard(key=nil)
if key
@next.delete(key)
else
@next = Hash.new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def any_time\n times(-1)\n end",
"def next_times(count)\n\n next_time ? [ next_time ] : []\n end",
"def only_the_ones_we_care_about\n @observations.shift while @observations.first[:observed_at] <= @last_observation_at\n return @observations\n end",
"def only_the_ones_we_care_about\n @observ... | [
"0.5600413",
"0.53169525",
"0.5267715",
"0.5267715",
"0.52279353",
"0.52217263",
"0.5219745",
"0.5207182",
"0.5195267",
"0.51372117",
"0.5133325",
"0.5131782",
"0.5092152",
"0.5068212",
"0.5050917",
"0.5031252",
"0.5030492",
"0.49963948",
"0.49952447",
"0.49890858",
"0.498580... | 0.0 | -1 |
get days of venue and all individual courts | def all_offdays
offdays = []
self.courts.includes(:day_offs).each do |c|
offdays = offdays + c.day_offs
end
offdays = offdays + self.day_offs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @venue = Venue.find(params[:id])\n @events = @venue.events.starting_today\n separate_events_by_date\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def index\n #@event_days = EventDay.all\n @event_days = Ev... | [
"0.64003164",
"0.6141678",
"0.607428",
"0.606383",
"0.6031406",
"0.60063773",
"0.59859467",
"0.59731436",
"0.59620297",
"0.5954683",
"0.5938702",
"0.5924709",
"0.592214",
"0.5906989",
"0.5900928",
"0.5900345",
"0.588337",
"0.58668274",
"0.58413285",
"0.5825392",
"0.58005196",... | 0.64977425 | 0 |
check that date can be booked while respecting booking ahead limit | def bookable?(date)
date < booking_date_limit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_date_valid?\n\t\tunless self.date_of_booking >= Time.zone.now.beginning_of_day \n\t\t\tself.errors[:date_validation] << \"=> You can't book resource for previous day\"\n\t\tend\n\tend",
"def checkIfBooked\n booking_start_time = Time.parse(get_booking[\"date\"].to_s)\n hours_booked = get_book... | [
"0.75921786",
"0.74825025",
"0.73254526",
"0.7145027",
"0.7143492",
"0.70884275",
"0.705413",
"0.6994429",
"0.6960754",
"0.69202673",
"0.69188666",
"0.68970907",
"0.6889658",
"0.6873991",
"0.6872558",
"0.6850726",
"0.6831603",
"0.68009186",
"0.67848504",
"0.67588156",
"0.6712... | 0.8776851 | 0 |
returns map with court_id as key and array of shared courts as values | def shared_courts_map
shared_courts_map = {}
courts.each do |court|
shared_courts_map[court.id] = court.shared_courts
end
shared_courts_map
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reservations_shared_courts_json(start_date, end_date)\n reservations_json = reservations_between_dates(start_date, end_date).map do |r|\n r.as_json_for_calendar(id)\n end\n\n if has_shared_courts?\n shared_courts_hash = shared_courts_map\n shared_reservations_json = reservations_json.ma... | [
"0.6149298",
"0.5959645",
"0.5715521",
"0.5645992",
"0.5555401",
"0.5425115",
"0.54215276",
"0.542078",
"0.540231",
"0.53443056",
"0.52576023",
"0.52533305",
"0.5251412",
"0.52512693",
"0.52203757",
"0.51986545",
"0.5171139",
"0.51629627",
"0.5158946",
"0.509951",
"0.50787973... | 0.8436736 | 0 |
returns actual reservations along with their copies for shared courts to indicate bookings in shared courts | def reservations_shared_courts_json(start_date, end_date)
reservations_json = reservations_between_dates(start_date, end_date).map do |r|
r.as_json_for_calendar(id)
end
if has_shared_courts?
shared_courts_hash = shared_courts_map
shared_reservations_json = reservations_json.map do |r|
shared_courts_hash[r[:resourceId]].map do |shared_court|
resv_court = Court.find(r[:resourceId])
r_copy = r.dup
r_copy[:title] += " - #{resv_court.court_name} (#{resv_court.sport_name})"
r_copy[:resourceId] = shared_court.id
r_copy
end
end.flatten
end
reservations_json + shared_reservations_json.to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reservations\n @reservations ||= flight.reservations\n end",
"def build_reservations\n # IMPORTANT: .take_matching_resell should be called before validations\n reservations = @bookings.map { |booking| Reservation.new(booking).take_matching_resell }\n all_valid = reservations.all? { |reservat... | [
"0.6469014",
"0.6279258",
"0.61871123",
"0.6097048",
"0.60130864",
"0.5973522",
"0.59516114",
"0.59326816",
"0.5892787",
"0.58624667",
"0.5839936",
"0.58387214",
"0.5779796",
"0.57400215",
"0.5709012",
"0.5646372",
"0.56256217",
"0.56125915",
"0.55926394",
"0.55920976",
"0.55... | 0.68840975 | 0 |
Evaluate the expression and save the result as the after value, to be compared with the expected value. | def eval_after
self.after_value = eval_expression
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _expression\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_assignment)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_value)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_expression unless _tmp\n return _t... | [
"0.6608152",
"0.6116787",
"0.601073",
"0.5899148",
"0.58897775",
"0.58266985",
"0.5819168",
"0.5812378",
"0.58115566",
"0.58029336",
"0.5800918",
"0.5734225",
"0.5728139",
"0.5727431",
"0.56601125",
"0.56593263",
"0.5636135",
"0.56061834",
"0.5603445",
"0.5602307",
"0.5601968... | 0.7570733 | 0 |
Returns whether the expectation passed or not. | def passed?
if expected_value.is_a?(Range)
expected_value.include?(after_value)
else
expected_value == after_value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def passed?\n return @test_passed\n end",
"def expected?\n false\n end",
"def passed?\n failures.empty?\n end",
"def passed?\n !failed?\n end",
"def passed?\n !failed?\n end",
"def success?\n got.equal?(true)\n end",
"def flexmock_test_has_failed?... | [
"0.75121814",
"0.7392998",
"0.73749197",
"0.72880054",
"0.7241032",
"0.7229363",
"0.7216972",
"0.7193618",
"0.7176227",
"0.7144335",
"0.70332634",
"0.7023078",
"0.69706607",
"0.6954971",
"0.6942237",
"0.6906023",
"0.68962055",
"0.6878534",
"0.68448305",
"0.68194836",
"0.68194... | 0.6301401 | 69 |
Generates the error message for this expectation. Returns nil if the expectation passed. | def error_message
unless passed?
"#{expression.inspect} didn't change by #{expected_difference} (expecting #{expected_value}, but got #{after_value})"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure_message\n \"expected #{@target.name} to provide #{@expected}, but it doesn't\"\n end",
"def failure_message\n @message\n end",
"def error\n valid? ? nil : @error_message\n end",
"def failure_message\n actual = prettify_args(@actual)\n\n if @description\n ... | [
"0.6920347",
"0.6743232",
"0.66533124",
"0.6632791",
"0.65205294",
"0.64865166",
"0.6452269",
"0.6445188",
"0.6425236",
"0.6404102",
"0.6386977",
"0.63751763",
"0.63743263",
"0.63741606",
"0.6359859",
"0.6355274",
"0.6328154",
"0.63127357",
"0.6282384",
"0.62415195",
"0.61757... | 0.64556164 | 6 |
Generate the expected value. | def generate_expected_value
if expected_difference.is_a? Range
(before_value + expected_difference.first)..(before_value + expected_difference.end)
else
before_value + expected_difference
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_value; end",
"def expected_value; end",
"def expected_value\n @expected_value ||= @expected_value_set ? @expected_value : get_attribute_from_rendered_object\n end",
"def value(expected)\n take(1) do |first, input, rest|\n\n if first[0] == :val && expected === first[1]... | [
"0.7435625",
"0.7435625",
"0.6742599",
"0.6526987",
"0.6471663",
"0.62628955",
"0.61519456",
"0.61141324",
"0.61141324",
"0.6061108",
"0.596703",
"0.5939972",
"0.5931912",
"0.5924148",
"0.58307016",
"0.5808427",
"0.5808041",
"0.57860947",
"0.578164",
"0.5769118",
"0.57670903"... | 0.7675367 | 0 |
Evaluate the expression in the context of the binding. | def eval_expression
eval(expression, binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(expr)\n @api.function_for_object_method(self, :eval).call(@session, expr)\n end",
"def eval_expression\n @evaluated_expression =\n ConlangWordGenerator::run_expression(@full_expression, @bindings)\n end",
"def evaluate(expr = nil, path=nil, line=nil, &bl)\n return instan... | [
"0.74297225",
"0.723196",
"0.71881324",
"0.70652866",
"0.6955886",
"0.69112176",
"0.67477834",
"0.66995674",
"0.66798127",
"0.66503847",
"0.6627945",
"0.6580601",
"0.65407825",
"0.6478736",
"0.63257927",
"0.63257927",
"0.62920046",
"0.6291804",
"0.6268858",
"0.6252002",
"0.62... | 0.82307756 | 0 |
Test if an error is thrown when an invalid key is provided | def test_invalid_key
api_key = 'invalid_key'
assert_raise Twizo::TwizoError do
@twizo = Twizo::Twizo.new(api_key, API_HOST)
widget = @twizo.create_registration_widget(NUMBER1)
widget.send
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_error?(key, value)\n case key\n when 'api_token_secret_key' then true if value.empty? ||\n value !~ /\\Askey_[a-zA-Z0-9]+\\z/\n\n when 'account_alias' then true if value.empty? ||\n value.length > 15 ... | [
"0.72801363",
"0.7231603",
"0.70715487",
"0.69853085",
"0.6967971",
"0.69014424",
"0.6893706",
"0.68932825",
"0.6809794",
"0.680836",
"0.68009466",
"0.6800086",
"0.67714435",
"0.67302364",
"0.6706841",
"0.6656507",
"0.66285056",
"0.65717286",
"0.6566636",
"0.6561097",
"0.6541... | 0.0 | -1 |
Test creation of a widget session | def test_create_widget
widget = @twizo.create_registration_widget(nil)
test_recipient = NUMBER1
widget.params.recipient = test_recipient
widget = widget.send
assert_equal test_recipient, widget.recipient
assert_not_nil widget.sessionToken
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_widget_session_encapsulation\n r = cell(:my_test, :some, 'root')\n r << a= cell(:my_test, :some, 'a')\n r << b1= cell(:my_test, :some, 'b')\n a << b2= cell(:my_test, :some, 'b')\n \n freeze_tree_for(r, session)\n \n assert_equal session['apotomo_widget_content'].size, 4\n ... | [
"0.61271",
"0.5873859",
"0.58506244",
"0.58506244",
"0.5685974",
"0.56859475",
"0.56712365",
"0.56712365",
"0.5636231",
"0.5609181",
"0.5564053",
"0.5539778",
"0.55004686",
"0.54935914",
"0.546422",
"0.5451479",
"0.5446227",
"0.544231",
"0.5421213",
"0.5419812",
"0.54077625",... | 0.6309915 | 0 |
Test widget session allowed types | def test_widget_type
widget = @twizo.create_registration_widget(nil)
widget.params.allowed_types = ['sms']
test_recipient = NUMBER1
widget.params.recipient = test_recipient
widget = widget.send
assert_equal test_recipient, widget.recipient
assert_equal ['sms'], widget.allowedTypes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validateType\n active = @types_nr[glade.get_widget(\"cmbType\").get_active]\n if active == \"mysql\" || active == \"postgresql\" || active == \"mysqli\" || active == \"mssql\"\n @gui[:texIP].show\n @gui[:texUsername].show\n @gui[:texPassword].show\n @gui[:texPort].show\n @gui[:te... | [
"0.6111192",
"0.60599464",
"0.60599464",
"0.59301645",
"0.5809037",
"0.55785567",
"0.5522824",
"0.54941887",
"0.5479108",
"0.5430035",
"0.54220796",
"0.54198706",
"0.54198706",
"0.5388424",
"0.53489405",
"0.5316414",
"0.5311921",
"0.52774876",
"0.5273123",
"0.52676314",
"0.52... | 0.64051175 | 0 |
Test widget session allowed types invalid | def test_widget_type_invalid
widget = @twizo.create_registration_widget(nil)
widget.params.allowed_types = 'sms'
test_recipient = NUMBER1
widget.params.recipient = test_recipient
assert_raise Twizo::TwizoError do
widget = widget.send
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_not_allowed\n negotiator = AssociationNegotiator.new([])\n negotiator.instance_eval{\n @allowed_types = [['assoc_bogus', 'session_bogus']]\n }\n msg = mk_message({'error' => 'Unsupported type',\n 'error_code' => 'unsupported-type',\n ... | [
"0.61162335",
"0.6022399",
"0.5968928",
"0.59080005",
"0.5743695",
"0.57083315",
"0.5702207",
"0.5702207",
"0.5690434",
"0.5690434",
"0.56265944",
"0.5601982",
"0.560097",
"0.55842745",
"0.55451584",
"0.5518687",
"0.54953",
"0.5493362",
"0.54303974",
"0.5426593",
"0.5425894",... | 0.6532937 | 0 |
Write a function that accepts an integer N and returns a NxN spiral matrix. Examples matrix(2) [[1, 2], [4, 3]] matrix(3) [[1, 2, 3], [8, 9, 4], [7, 6, 5]] matrix(4) [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]] | def spiral_matrix(n)
result = []
n.times { result.push([])}
counter = 1;
start_column = 0; end_column = n - 1
start_row = 0; end_row = n - 1
while start_column <= end_column && start_row <= end_row
(start_column..end_column).each do |i|
result[start_row][i] = counter
counter += 1
end
start_row += 1
(start_row..end_row).each do |i|
result[i][end_column] = counter
counter += 1
end
end_column -= 1
(start_column..end_column).reverse_each do |i|
result[end_row][i] = counter
counter += 1
end
end_row -= 1
(start_row..end_row).reverse_each do |i|
result[i][start_column] = counter
counter += 1
end
start_column += 1
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spiral(n)\n results = []\n n.times do\n results << []\n end\n results\n\n counter = 1\n start_column = 0\n end_column = n - 1\n start_row = 0\n end_row = n - 1\n\n while start_column <= end_column && start_row <= end_row\n # top row\n loop do\n i = start_column\n results[start_row]... | [
"0.7780408",
"0.7522224",
"0.73444736",
"0.7092348",
"0.70736134",
"0.7043761",
"0.6462332",
"0.6461849",
"0.62283057",
"0.6212269",
"0.61955184",
"0.6173878",
"0.61624783",
"0.61269563",
"0.6073745",
"0.60562646",
"0.60347265",
"0.60329217",
"0.6007138",
"0.59716046",
"0.592... | 0.80019766 | 0 |
Where to find plugin files. alias_method :source, :location TODO: rename to 'destination' | def output
@output ||= (
#if session.create? && plugin.name #scaffold && session.scaffold?
# session.output + plugin.name
#else
session.destination
#end
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plugin_directory; end",
"def plugins_path; end",
"def copy_plugin_directories\n %w[\n config lib\n ].each { |dir| directory(dir, \"#{extension_name}/#{dir}\") }\n end",
"def plugin_dir(path:)\n add option: \"-plugin-dir=#{path}\"\n end",
"def source_paths\n [__dir__]\ne... | [
"0.7385625",
"0.68645436",
"0.6489006",
"0.64753705",
"0.6449008",
"0.6449008",
"0.6389348",
"0.63758874",
"0.6327385",
"0.63167334",
"0.6296086",
"0.6296086",
"0.6296086",
"0.62909603",
"0.62909603",
"0.62909603",
"0.62909603",
"0.62909603",
"0.62909603",
"0.6231264",
"0.621... | 0.0 | -1 |
Newuse of sow? In other words, is the destination empty? | def newproject?
session.new?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_not_in_dest; end",
"def destination(dest); end",
"def destination(dest); end",
"def isdst() end",
"def destination_empty?\n Dir['*'].length == 0 \n end",
"def empty?\n copies.empty?\n end",
"def check_if_destination_empty(destination_arr)\n\t\tif the_board.position_status(destina... | [
"0.63884026",
"0.63124883",
"0.63124883",
"0.6096928",
"0.5990981",
"0.5764149",
"0.5742591",
"0.57125753",
"0.5706107",
"0.5701206",
"0.5665792",
"0.55718416",
"0.55545235",
"0.5544425",
"0.5535756",
"0.5521195",
"0.55184996",
"0.5500827",
"0.54994446",
"0.5496142",
"0.54961... | 0.0 | -1 |
Main command called to generate files. | def generate #(args, opts)
actionlist = actionlist(copylist)
if actionlist.empty?
logger.report_nothing_to_generate
return
end
source = '' # FIXME
logger.report_startup(source, output)
mkdir_p(output) #unless File.directory?(output)
Dir.chdir(output) do
actionlist.each do |action, loc, src, dest, opts|
atime = Time.now
result, fulldest = *__send__(action, loc, src, dest, opts)
logger.report_create(relative_to_output(dest), result, atime)
#logger.report_create(dest, result, atime)
end
end
logger.report_complete
logger.report_fixes #if session.newproject?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate\n if @options.dry_run then\n # do nothing\n @generator.generate\n else\n Dir.chdir @options.op_dir do\n unless @options.quiet then\n $stderr.puts \"\\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}...\"\n end\n\n @generato... | [
"0.70301795",
"0.6941933",
"0.6913652",
"0.6721605",
"0.6654339",
"0.66415715",
"0.662587",
"0.65283555",
"0.651247",
"0.6505634",
"0.6497613",
"0.6358729",
"0.63304925",
"0.63192755",
"0.62834424",
"0.62714154",
"0.62570316",
"0.6245348",
"0.62356913",
"0.62317365",
"0.61430... | 0.6806534 | 3 |
If in prompt mode, returns a list filtered of overwrites as selected by the user. If in skip mode, mark duplicates to skipped. If not in prompt or skip mode, simply return the current list. | def actionlist_safe(list)
return list unless (prompt? or skip?)
return list if list.empty?
safe = []
dups = []
list.each do |action, loc, tname, fname, opts|
dups << [action, loc, tname, fname, opts, (output + fname).file?]
end
puts "Select (y/n) which files to overwrite:\n" if prompt? unless quiet?
dups.each do |action, loc, tname, fname, opts, check|
if check
if skip?
safe << [:skip, loc, tname, fname, opts]
else
f = relative_to_output(fname)
case ans = ask(" #{f}? ").downcase.strip
when 'y', 'yes'
safe << [action, loc, tname, fname, opts]
else
safe << [:skip, loc, tname, fname, opts]
end
end
else
safe << [action, loc, tname, fname, opts]
end
end
puts
return safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actionlist_safe(action, list)\n return list unless (prompt? or skip?)\n return list if list.empty?\n safe = []\n dups = []\n list.each do |action, fname|\n dups << [action, fname, (output + fname).file?]\n end\n report \"Select (y/n) which files to overwrite:\\n\" if p... | [
"0.5846193",
"0.54627347",
"0.52745014",
"0.5247604",
"0.51744413",
"0.5109783",
"0.5068006",
"0.50653225",
"0.50258523",
"0.5015235",
"0.50070953",
"0.49690318",
"0.49339476",
"0.49212745",
"0.49024338",
"0.48868015",
"0.48823318",
"0.4863572",
"0.4851266",
"0.47944766",
"0.... | 0.6163957 | 0 |
Check for any overwrites. If generator allows overwrites this will be skipped, otherewise an error will be raised. TODO: Make this a list filter with check for "identical" files? | def check_overwrite(list)
return if force?
return if prompt?
return if skip?
#return if session.overwrite? # TODO: not so sure overwirte? option is a good idea.
if newproject? && !output.glob('**/*').empty? # FIXME?
abort "New project isn't empty. Use --force, --skip or --prompt."
end
clobbers = []
list.each do |action, loc, tname, fname, opts|
tpath = loc + tname
fpath = output + fname
if fpath.file? #fpath.exist?
clobbers << relative_to_output(fname)
end
end
if !clobbers.empty?
puts " " + clobbers.join("\n ")
abort "These files would be overwritten. Use --force, --skip or --prompt." # TODO: implement --skip
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_overwrite(list)\n return if write?\n return if prompt?\n return if skip?\n #if newproject? && !output.glob('**/*').empty? # FIXME?\n # abort \"New project isn't empty. Use --force, --skip or --prompt.\"\n #end\n clobbers = []\n list.each do |action, fname|\n ... | [
"0.7038695",
"0.6643011",
"0.62357205",
"0.61056536",
"0.58157784",
"0.58030653",
"0.57826006",
"0.5744166",
"0.56414235",
"0.56161654",
"0.5589676",
"0.55888957",
"0.55631644",
"0.5562999",
"0.5549852",
"0.5542577",
"0.5541816",
"0.55114716",
"0.5465433",
"0.54357773",
"0.54... | 0.66128796 | 2 |
Check for any clashing generations, ie. a directory that will overwrite a file or a file that will overwrite a directory. This will raise an error if any of these conditions are found, unless force? is set to true. | def check_conflicts(list)
#return if force?
list.each do |action, loc, tname, fname, opts|
tpath = loc + tname
fpath = output + fname
if File.exist?(fpath)
if tpath.directory?
if !fpath.directory?
raise "Directory to be created clashes with a pre-existent file -- #{fname}"
end
else
if fpath.directory?
raise "File to be created clashes with a pre-existent directory -- #{fname}"
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_on_collision?\n base.shell.file_collision(destination){ render }\n end",
"def check_conflicts(list)\n #return if write?\n list.each do |action, fname|\n tpath = source + fname\n fpath = output + fname\n if File.exist?(fpath)\n if tpath.directory?\n ... | [
"0.61031306",
"0.60529363",
"0.5967392",
"0.57419103",
"0.5534598",
"0.5510736",
"0.5377114",
"0.5347375",
"0.52975535",
"0.5284525",
"0.5254084",
"0.5208088",
"0.519733",
"0.5182151",
"0.5038816",
"0.50353533",
"0.5028541",
"0.5018368",
"0.49998122",
"0.49880174",
"0.4962239... | 0.69109994 | 0 |
FIXME def relative_to_source(src) Pathname.new(src).relative_path_from(source) end | def relative_to_output(dest)
if dest =~ /^\//
Pathname.new(dest).relative_path_from(output)
else
dest
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source_path\n File.expand_path source unless source.nil?\n end",
"def relative_src(filename, dir=nil)\n file = expand_src filename, dir\n base = Pathname.new File.dirname path_info\n Pathname.new(file).relative_path_from(base).to_s\n end",
"def relative(filename)\n filename.sub(%... | [
"0.8056754",
"0.80526",
"0.7964445",
"0.7884044",
"0.7831005",
"0.7728726",
"0.76361126",
"0.76173824",
"0.75480515",
"0.75480515",
"0.74524266",
"0.7427275",
"0.7410278",
"0.7403391",
"0.73685956",
"0.73412526",
"0.73412526",
"0.73412526",
"0.73412526",
"0.73412526",
"0.7177... | 0.6525053 | 98 |
this gets the symbol of the piece | def symbol
@color
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def piece_name(p)\n if p.class.to_s == \"Symbol\"\n (p == :knight ? :night : p).to_s.downcase.split('').first\n else\n PIECES[p.downcase]\n end\n end",
"def symbol\n \n end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"... | [
"0.70251757",
"0.6689309",
"0.6546645",
"0.6546645",
"0.6546645",
"0.6546645",
"0.6546645",
"0.6546645",
"0.6483682",
"0.64737594",
"0.64238566",
"0.6391715",
"0.63788956",
"0.63679993",
"0.617328",
"0.615538",
"0.61424106",
"0.60829175",
"0.6075657",
"0.6075492",
"0.6075043"... | 0.631042 | 14 |
this gets the color of the piece | def to_s
@color
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def piece_color(piece); ((piece.color == :white) ? \"#FFEED5\" : \"#063848\") end",
"def piece_color(index)\n return @@pieces[index][\"color\"]\n end",
"def piece_color(index)\n Move.pieces[index][:color]\n end",
"def get_color\n @color\n end",
"def color\n return @color\... | [
"0.83723646",
"0.8126306",
"0.7983014",
"0.7619411",
"0.74386054",
"0.74386054",
"0.74168056",
"0.73825884",
"0.73733693",
"0.71904343",
"0.7177628",
"0.71719265",
"0.71719265",
"0.7148938",
"0.71139055",
"0.7074793",
"0.70035356",
"0.691555",
"0.6902598",
"0.6902598",
"0.690... | 0.0 | -1 |
Used for checking visibility of attribute on an view | def visible?(action, default: true)
options.fetch(action.to_sym, default)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_visible?\n visibility && ( visibility > 0 )\n end",
"def visible?\n end",
"def visible?\n model.respond_to?(:visibility) && model.visibility.include?(Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC)\n end",
"def IsVisibleOnPortal # rubocop:disable Style/MethodName\n @att... | [
"0.7179527",
"0.7050202",
"0.7043823",
"0.6908439",
"0.6843081",
"0.6788489",
"0.6782014",
"0.67803264",
"0.6689772",
"0.66530144",
"0.66041577",
"0.6580285",
"0.6569244",
"0.6549737",
"0.6549737",
"0.6549737",
"0.6549737",
"0.6549737",
"0.65409225",
"0.65409225",
"0.653315",... | 0.0 | -1 |
Provide pin + options | def choose(pw)
puts "Please enter your pin #"
pw = gets.chomp
if pw == "#{$pin}"
puts "What do you need from your vault?
withdraw
deposit
balance
end"
action = gets.chomp
#defining actions
case action
when "balance" then display_balance
when "withdraw" then puts "How much would you like to withdraw? (multiples of $1 only)"
amount = gets.chomp.gsub(/\D/,'').to_i
withdraw(amount)
when "deposit" then puts "How much would you like to deposit? (multiples of $1 only)"
amount = gets.chomp.gsub(/\D/,'').to_i
deposit(amount)
when "end" then puts "Have a wonderful day!"
else return home
end
else
puts "Sorry, that pin won't work for your vault. Please try again."
return choose(" ")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pin\n @pin = 1234\n end",
"def input_pin(num, opts={})\n raise ArgumentError, \"can only define pin from Fixnum, got #{num.class}\" unless num.is_a?(Fixnum)\n @pin_modes[:input] << num\n if opts[:as]\n # transitioning to :device => :button syntax\n if opts[:latch] || opts[:device] == :... | [
"0.677741",
"0.655505",
"0.65073746",
"0.6498961",
"0.6486996",
"0.6468362",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.6167357",
"0.61591244",
"0.61541235",
"0.61440706",
"0.6132375",
"0.6127869",
... | 0.0 | -1 |
GET /solicitacao_repasses or /solicitacao_repasses.json | def index
@solicitacao_repasses = SolicitacaoRepasse.all
@solicitacoes = []
@solicitacao_repasses.each { |solicitacao|
@encomenda = EntregaExterna.find(params[:id], solicitacao.entrega_externa_id)
if !@current_user.isMorador || @encomenda.encomenda.usuario.id == @current_user.id
@solicitacoes.push(solicitacao)
end
}
@solicitacao_repasses = @solicitacoes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_solicitacao_repasse\n @solicitacao_repass = SolicitacaoRepasse.find(params[:id])\n end",
"def index\n @solicitacoes = Solicitacao.all\n end",
"def index\n @respuestas = Respuesta.all\n end",
"def index\n @solicitacao_pontuals = SolicitacaoPontual.all\n end",
"def index\n ... | [
"0.68686134",
"0.6079394",
"0.6063554",
"0.60403866",
"0.60274285",
"0.60113716",
"0.6009972",
"0.5996097",
"0.5935381",
"0.5927773",
"0.5902989",
"0.58707047",
"0.5749739",
"0.5735485",
"0.5729349",
"0.57122713",
"0.5708835",
"0.56970644",
"0.5659603",
"0.5652519",
"0.562377... | 0.71895444 | 0 |
GET /solicitacao_repasses/1 or /solicitacao_repasses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_solicitacao_repasse\n @solicitacao_repass = SolicitacaoRepasse.find(params[:id])\n end",
"def index\n @solicitacao_repasses = SolicitacaoRepasse.all\n @solicitacoes = []\n @solicitacao_repasses.each { |solicitacao|\n @encomenda = EntregaExterna.find(params[:id], solicitacao.entrega_exte... | [
"0.6664556",
"0.6386223",
"0.6016489",
"0.59136575",
"0.58535147",
"0.5853248",
"0.5853016",
"0.58346033",
"0.57523066",
"0.5728601",
"0.5646482",
"0.5586104",
"0.5572042",
"0.55223995",
"0.5520015",
"0.5518188",
"0.55008864",
"0.5478156",
"0.54755986",
"0.5471018",
"0.546935... | 0.0 | -1 |
POST /solicitacao_repasses or /solicitacao_repasses.json | def create
@solicitacao_repass = SolicitacaoRepasse.new(solicitacao_repasse_params)
@entregas_externas = EntregaExterna.all
@entregas_externas_usuario = []
@entregas_externas.each { |entrega|
if !@current_user.isMorador || entrega.encomenda.usuario.id == @current_user.id
@entregas_externas_usuario.push(entrega)
end
}
respond_to do |format|
if @solicitacao_repass.save
format.html { redirect_to @solicitacao_repass, notice: "Solicitacao repasse was successfully created." }
format.json { render :show, status: :created, location: @solicitacao_repass }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @solicitacao_repass.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_solicitacao_repasse\n @solicitacao_repass = SolicitacaoRepasse.find(params[:id])\n end",
"def solicitacao_repasse_params\n params.require(:solicitacao_repasse).permit(:dataSolicitada, :entrega_externa_id)\n end",
"def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |f... | [
"0.68037564",
"0.6600813",
"0.63467693",
"0.6283298",
"0.62776065",
"0.62616825",
"0.6223372",
"0.6172709",
"0.61473507",
"0.6094296",
"0.6083899",
"0.6064474",
"0.6048373",
"0.60046786",
"0.6000547",
"0.5995385",
"0.5964179",
"0.5958901",
"0.59247434",
"0.59221977",
"0.59096... | 0.67774713 | 1 |
PATCH/PUT /solicitacao_repasses/1 or /solicitacao_repasses/1.json | def update
respond_to do |format|
if @solicitacao_repass.update(solicitacao_repasse_params)
format.html { redirect_to @solicitacao_repass, notice: "Solicitacao repasse was successfully updated." }
format.json { render :show, status: :ok, location: @solicitacao_repass }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @solicitacao_repass.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @solicitacao.update(solicitacao_params)\n format.html { redirect_to @solicitacao, notice: 'Solicitacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { ren... | [
"0.6853419",
"0.6771387",
"0.67480016",
"0.6610324",
"0.66022843",
"0.64907944",
"0.64575785",
"0.6396338",
"0.6390979",
"0.6363933",
"0.6360611",
"0.6283719",
"0.624811",
"0.6244114",
"0.6233545",
"0.62186915",
"0.61841226",
"0.6145675",
"0.61341864",
"0.608589",
"0.60833406... | 0.7296852 | 0 |
DELETE /solicitacao_repasses/1 or /solicitacao_repasses/1.json | def destroy
@solicitacao_repass.destroy
respond_to do |format|
format.html { redirect_to solicitacao_repasses_url, notice: "Solicitacao repasse was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redire... | [
"0.74362266",
"0.7398842",
"0.7358588",
"0.7355925",
"0.7342058",
"0.73252195",
"0.73252195",
"0.729599",
"0.72777253",
"0.72693074",
"0.7269173",
"0.72527385",
"0.71988225",
"0.7153878",
"0.7153878",
"0.71451634",
"0.71441036",
"0.7090701",
"0.7079296",
"0.70785993",
"0.7064... | 0.79201394 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_solicitacao_repasse
@solicitacao_repass = SolicitacaoRepasse.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 list of trusted parameters through. | def solicitacao_repasse_params
params.require(:solicitacao_repasse).permit(:dataSolicitada, :entrega_externa_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69485277",
"0.6813547",
"0.6799911",
"0.6796169",
"0.6745757",
"0.6741778",
"0.6527065",
"0.65204644",
"0.64925444",
"0.64314413",
"0.64314413",
"0.64314413",
"0.6398711",
"0.6355623",
"0.6355327",
"0.6345812",
"0.6343951",
"0.6338371",
"0.6327366",
"0.6327366",
"0.6327366... | 0.0 | -1 |
Idobata does not support these methods. | def join; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def interface; end",
"def interface; end",
"def data_attributes\n end",
"def ibu; end",
"def operation_method\n raise 'Not implemented!'\n end",
"def identify; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"de... | [
"0.616725",
"0.5934118",
"0.5934118",
"0.58211774",
"0.5814242",
"0.5798713",
"0.579777",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.5786343",
"0.57667917",
"0.57512265",
... | 0.0 | -1 |
GET /brand_categories GET /brand_categories.json | def index
@brand_categories = BrandCategory.all
render json: @brand_categories
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_ba... | [
"0.7578071",
"0.7522996",
"0.7265907",
"0.7190053",
"0.69770247",
"0.69134706",
"0.68275416",
"0.6794319",
"0.6759494",
"0.6755859",
"0.6701426",
"0.6693287",
"0.6665395",
"0.66608727",
"0.660945",
"0.660717",
"0.66068846",
"0.66068846",
"0.65865004",
"0.65807",
"0.65715617",... | 0.79234666 | 0 |
GET /brand_categories/1 GET /brand_categories/1.json | def show
render json: @brand_category
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @brand_categories = BrandCategory.all\n\n render json: @brand_categories\n end",
"def show\n @brand_category = BrandCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brand_category }\n end\n end",
"def get_ca... | [
"0.7906568",
"0.73191255",
"0.7259167",
"0.71906286",
"0.69458395",
"0.6885645",
"0.68757296",
"0.67348963",
"0.6729015",
"0.6715758",
"0.670219",
"0.6692397",
"0.66825587",
"0.6680883",
"0.6650268",
"0.6637357",
"0.6628574",
"0.66284996",
"0.66284996",
"0.66072786",
"0.65917... | 0.75079787 | 1 |
POST /brand_categories POST /brand_categories.json | def create
@brand_category = BrandCategory.new(brand_category_params)
if @brand_category.save
render json: @brand_category, status: :created, location: @brand_category
else
render json: @brand_category.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @brand_category = BrandCategory.new(params[:brand_category])\n\n respond_to do |format|\n if @brand_category.save\n format.html { redirect_to @brand_category, notice: 'Brand category was successfully created.' }\n format.json { render json: @brand_category, status: :created, l... | [
"0.71133125",
"0.6930579",
"0.68703383",
"0.6819658",
"0.6788928",
"0.6690035",
"0.66820157",
"0.66783744",
"0.66663224",
"0.66651106",
"0.6654922",
"0.6499708",
"0.64703655",
"0.6468897",
"0.6415448",
"0.63389796",
"0.626447",
"0.6262298",
"0.62536186",
"0.6252522",
"0.62495... | 0.75915146 | 0 |
PATCH/PUT /brand_categories/1 PATCH/PUT /brand_categories/1.json | def update
if @brand_category.update(brand_category_params)
head :no_content
else
render json: @brand_category.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n json_update(category,category_params, Category)\n end",
"def update\n @brand_category = BrandCategory.find(params[:id])\n\n respond_to do |format|\n if @brand_category.update_attributes(params[:brand_category])\n format.html { redirect_to @brand_category, notice: 'Brand categor... | [
"0.7167188",
"0.7156717",
"0.69433606",
"0.6704825",
"0.6663778",
"0.66340744",
"0.6564461",
"0.6562207",
"0.6450248",
"0.64267945",
"0.6417815",
"0.64104193",
"0.6398346",
"0.6378503",
"0.6374551",
"0.6363993",
"0.635139",
"0.6329864",
"0.629489",
"0.6285019",
"0.62812066",
... | 0.7466341 | 0 |
DELETE /brand_categories/1 DELETE /brand_categories/1.json | def destroy
@brand_category.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @brand_category = BrandCategory.find(params[:id])\n @brand_category.destroy\n\n respond_to do |format|\n format.html { redirect_to brand_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n fo... | [
"0.78719914",
"0.738768",
"0.7318098",
"0.7312217",
"0.7261534",
"0.72493035",
"0.7246214",
"0.72441524",
"0.71795696",
"0.7163738",
"0.7142588",
"0.7131343",
"0.7121295",
"0.70545",
"0.70234054",
"0.70095474",
"0.70095474",
"0.70095474",
"0.70095474",
"0.69974774",
"0.699183... | 0.7784845 | 1 |
Preview this email at | def password_reset
user = Customer.last
user.reset_token = Customer.new_token
CustomerMailer.password_reset(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview_email\r... | [
"0.71475905",
"0.71186084",
"0.70552814",
"0.6985626",
"0.6848472",
"0.6848472",
"0.6832406",
"0.6663229",
"0.64324814",
"0.631654",
"0.6304366",
"0.6181875",
"0.6167911",
"0.61338973",
"0.61305445",
"0.6115152",
"0.61100966",
"0.61100966",
"0.60882556",
"0.60132533",
"0.5982... | 0.0 | -1 |
what is this? what happens if it were cut and pasted above the virus_effects method | def predicted_deaths(population_density, population, state)
if @population_density < 50
number_of_deaths = (@population * 0.05).floor
else
number_of_deaths = (@population_density * (0.1 * (@population / 50)) ).floor
end
# if @population_density >= 200
# number_of_deaths = (@population * 0.4).floor
# elsif @population_density >= 150
# number_of_deaths = (@population * 0.3).floor
# elsif @population_density >= 100
# number_of_deaths = (@population * 0.2).floor
# elsif @population_density >= 50
# number_of_deaths = (@population * 0.1).floor
# else
# number_of_deaths = (@population * 0.05).floor
# end
print "#{@state} will lose #{number_of_deaths} people in this outbreak"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virus_effects\r\n predicted_deaths()\r\n speed_of_spread()\r\n end",
"def virus_effects\r\n predicted_deaths()\r\n speed_of_spread()\r\n end",
"def virus_effects\n display_report\n end",
"def virus_effects\n predicted_deaths()\n speed_of_spread()\n end",
"def virus_effects\n ... | [
"0.7149153",
"0.7148251",
"0.7042237",
"0.7031812",
"0.7031812",
"0.7031812",
"0.69986963",
"0.6957982",
"0.6869425",
"0.6862788",
"0.68333834",
"0.6814915",
"0.68049675",
"0.68049675",
"0.6737442",
"0.6733971",
"0.672399",
"0.6718074",
"0.67132586",
"0.6696903",
"0.6696903",... | 0.0 | -1 |
add_song takes in an argument of a song and associates that song with the artist by telling the song that it belongs to that artist | def add_song(song)
@songs << song
song.artist = self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_song(song)\n # Add song to @songs if it doesn't already exist\n @songs << song if !@songs.include?(song)\n # Add artist if not already assigned\n song.artist = self if song.artist ==nil\n save\n end",
"def add_song(song) # Third, we create 'add_song' to associate a song name with a partic... | [
"0.86455953",
"0.8635153",
"0.8591736",
"0.8578977",
"0.8577607",
"0.8577607",
"0.8576847",
"0.8533006",
"0.8523354",
"0.8517687",
"0.84763986",
"0.8474131",
"0.8458367",
"0.8439131",
"0.8439131",
"0.8439131",
"0.8439131",
"0.8439131",
"0.8439131",
"0.8422865",
"0.8403434",
... | 0.8500854 | 20 |
add_song_by_name takes in an argument of a song name, creates a new song with it and associates the song and artist | def add_song_by_name(name)
song = Song.new(name)
@songs << song
song.artist = self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_song_by_name(song_name)\n # Create a new song called \"song\" with argument passed in.\n song = Song.new(song_name)\n # Associate it with the artist\n song.artist = self\n end",
"def add_song_by_name(song_name)\n song = Song.new(song_name)\n song.artist = self\n @songs << song\n e... | [
"0.89060813",
"0.87966543",
"0.87734556",
"0.8746295",
"0.8730603",
"0.8716872",
"0.86912054",
"0.86912054",
"0.8612915",
"0.8576572",
"0.8537992",
"0.8528644",
"0.8510314",
"0.840953",
"0.8269126",
"0.81974304",
"0.7942702",
"0.7821799",
"0.78193086",
"0.78115183",
"0.774064... | 0.8785329 | 2 |
demande au joueur 1 son nom | def ask_player1
puts " Pour commencer, que le premier joueur décline son identité !"
print " JOUEUR 1 : "
player1 = gets.chomp.to_s
puts " Ton symbole sera le X (OULALA)"
puts " "
return player1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devolver_nombre \n return @nombre\n end",
"def sigla; @nome; end",
"def chargementJeu(nomJoueur)\n @sauvegardeYaml = SauvegardeYAML.creer(nomJoueur)\n @sauvegarde = @sauvegardeYaml.chargement()\n @joueur = @sauvegarde.joueur\n nom=@joueur.nom.split(\".\")\n @joueur.nom ... | [
"0.63169265",
"0.62428254",
"0.6190768",
"0.58569616",
"0.58011025",
"0.5707326",
"0.56323117",
"0.5615091",
"0.5588328",
"0.5583987",
"0.5574686",
"0.5521639",
"0.5499483",
"0.5491796",
"0.54885757",
"0.5486485",
"0.5486076",
"0.5482805",
"0.5481284",
"0.5466597",
"0.5453442... | 0.0 | -1 |
demande au joueur 2 son nom | def ask_player2
puts " Pas de jaloux ici ! Joueur 2, a toi de décliner ton identité "
print " JOUEUR 2 : "
player2 = gets.chomp.to_s
puts " Ton symbole sera le O"
puts " "
puts " "
puts " Puisque vous avez été discipliné, la partie peut commencer !"
puts " Appuie sur entrée pour lancer le jeu"
gets.chomp
return player2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigla; @nome; end",
"def devolver_nombre \n return @nombre\n end",
"def chargementJeu(nomJoueur)\n @sauvegardeYaml = SauvegardeYAML.creer(nomJoueur)\n @sauvegarde = @sauvegardeYaml.chargement()\n @joueur = @sauvegarde.joueur\n nom=@joueur.nom.split(\".\")\n @joueur.nom ... | [
"0.62212515",
"0.611195",
"0.6107955",
"0.59525174",
"0.5730972",
"0.57218313",
"0.5664158",
"0.5649327",
"0.5585208",
"0.55725795",
"0.5564013",
"0.55571693",
"0.5511145",
"0.5490387",
"0.5447488",
"0.54431766",
"0.5440992",
"0.54221433",
"0.54179513",
"0.54029375",
"0.53935... | 0.0 | -1 |
demande aux joueurs s'ils veulent refaire une partie | def ask_again(game)
puts " Veux-tu rejouer ? OUI / NON"
print " > "
choice = gets.chomp
puts " "
while choice != "OUI" || choice != "NON"
case choice
when "OUI"
#si oui, relance du jeu
choice = " "
game.new_round
game.turn
when "NON"
#si non, fin du jeu avec tableau de fin
game.game_end
break
else
#si l'entrée n'est pas bonne, retourne à l'choice
puts " Veux-tu rejouer ? OUI / NON"
puts " Ecrit OUI ou NON en majuscules : "
print " > "
choice = gets.chomp
puts " "
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revisa_deuda\n if com_compra.adeudos[:cuentas_con_deuda] == 0\n com_compra.pagado!\n else\n com_compra.pendiente!\n end\n end",
"def destroy\n @equipe_perso.destroy\n respond_to do |format|\n format.html { redirect_to equipe_persos_url, success: \"Ton équipe a bien été supprimé... | [
"0.6113334",
"0.5953234",
"0.5936018",
"0.59135026",
"0.5905256",
"0.58856523",
"0.58609706",
"0.58454233",
"0.5793509",
"0.5771624",
"0.57359064",
"0.57278293",
"0.5700479",
"0.56839526",
"0.5663409",
"0.5658421",
"0.5649981",
"0.5624251",
"0.56176543",
"0.5606305",
"0.56035... | 0.0 | -1 |
generates an uuid using uuidtools and assigns it to the handbook | def assign_uuid
self.id = UUIDTools::UUID.timestamp_create().to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_uuid\n self.uuid = SecureRandom.hex(12)\n end",
"def populate_uuid\n self.uuid = SecureRandom.uuid()\n end",
"def assign_uuid\n self.uuid ||= SecureRandom.urlsafe_base64(8)\n end",
"def assign_uuid\n self.uuid ||= \"_#{SecureRandom.uuid.tr('-', '_')}\"\n end",
"def set_uuid\n ... | [
"0.7766986",
"0.77182597",
"0.76084286",
"0.75788295",
"0.75720835",
"0.75720835",
"0.7492911",
"0.7492882",
"0.7467044",
"0.7397426",
"0.73954564",
"0.7346677",
"0.7342362",
"0.7334562",
"0.73204124",
"0.7277922",
"0.72554445",
"0.72375715",
"0.72374344",
"0.72321403",
"0.72... | 0.7835983 | 0 |
user chooses event displays event | def get_months
@months = RiverEvents::Month.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_event(user, event) \n\tend",
"def show\n @page_title = \"Event Submitted: #{@user_event.title}\"\n end",
"def show\r\n @event = Event.find(params[:id])\r\n @theme = @event.theme\r\n @category = @event.category\r\n # event recurrence is limited to one of these 4 options, which are saved... | [
"0.7005703",
"0.6910906",
"0.6863966",
"0.66006154",
"0.65912265",
"0.6566955",
"0.6559449",
"0.65069336",
"0.6432502",
"0.64296633",
"0.63753414",
"0.63714504",
"0.6367392",
"0.63479984",
"0.63236713",
"0.63188136",
"0.6316713",
"0.6315148",
"0.6301987",
"0.630008",
"0.62999... | 0.0 | -1 |
For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6]. Followup: what if you can't use division? | def array_product_bruteforce(a)
prod = Array.new(a.size)
i = 0
while i < a.size
c = a[0..a.size]
c.delete_at(i)
prod[i] = c.inject(:*)
i += 1
end
return prod
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stretch list\n final_array = []\n list.each do |num|\n final_array << num - num/2\n final_array << num/2\n end\n return final_array\nend",
"def gc_divisor(ints:[]) \n arr = []\n arr2 = []\n for i in ints \n arr << i \n end\n \n arr.each do |num|\n for i in (1..num)\n if (num % i ==... | [
"0.67386496",
"0.64655375",
"0.6459174",
"0.637176",
"0.63554066",
"0.6299104",
"0.62724453",
"0.62656045",
"0.62643903",
"0.62545395",
"0.6221268",
"0.6168037",
"0.6163779",
"0.6157276",
"0.61426574",
"0.61411315",
"0.61278486",
"0.6126046",
"0.6088496",
"0.60683393",
"0.605... | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
#set initial placeholder variables to compare to each value everytime you iterate
min_value = false
min_key = false
if name_hash.empty? #check outside the loop so that the code in the loop runs
return nil
end
name_hash.each do | key, value | #start loop
if min_value == false #check to see if it's exactly identical to false first since it is not it will take the value of the first iteration
min_value = value #min_value is now equal to false
min_key = key
# we don't want min_value to stay false so we reset it below
elsif min_value > value # reset and assign the current value to the min value to compare and assign the lowest value
min_value = value
min_key = key
end
end
return min_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.88230467",
"0.877954",
"0.8779329",
"0.8747364",
"0.8690746",
"0.8657826",
"0.8654798",
"0.8618082",
"0.859029",
"0.8573832",
"0.85692596",
"0.8553887",
"0.8532013",
"0.8532013",
"0.8520662",
"0.8495162",
"0.8477513",
"0.8477513",
"0.846735",
"0.8451164",
"0.84508044",
"... | 0.0 | -1 |
def send_password_reset generate_token(:password_reset_token) self.password_reset_sent_at = Time.zone.now save! UserMailer.password_reset(self).deliver end | def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_password_reset\n generate_token(:password_reset_token)\n self.password_reset_sent_at = Time.zone.now\n save!\n UserMailer.password_reset(self).deliver \n end",
"def send_password_reset\n generate_token(:password_reset_token)\n self.password_reset_sent_at = Time.zone.now \n save!\n ... | [
"0.9677385",
"0.9634633",
"0.9601032",
"0.9560351",
"0.9558695",
"0.9556346",
"0.954754",
"0.9524029",
"0.9496214",
"0.9496214",
"0.9496214",
"0.9496214",
"0.94631284",
"0.9428995",
"0.9334369",
"0.9297687",
"0.9292888",
"0.92872405",
"0.91471446",
"0.91111004",
"0.907254",
... | 0.0 | -1 |
Adds highlight field params if a query was passed to the search parameters. | def add_full_text_context(params)
return unless blacklight_params[:q].present?
params['hl'] = true
params['hl.fl'] ||= []
params['hl.fl'] << 'extracted_text_tsimv'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_highlighting(solr_params)\n solr_params['hl'] = true\n solr_params['hl.fl'] = CatalogController.blacklight_config.highlight_field\n solr_params['hl.snippets'] = 3\n solr_params\n end",
"def highlight(*args)\n options = args.last.kind_of?(Hash) ? args.pop : {}\n fields... | [
"0.70859194",
"0.702693",
"0.68864864",
"0.6609844",
"0.6605684",
"0.6551294",
"0.65099406",
"0.6384885",
"0.6202662",
"0.61125326",
"0.60875165",
"0.6087028",
"0.6078974",
"0.6065672",
"0.59232885",
"0.58778495",
"0.57652134",
"0.5765091",
"0.57441634",
"0.566444",
"0.561454... | 0.0 | -1 |
GET /results GET /results.json | def index
@results = Result.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end",
"def results\n with_monitoring do\n response = perform(:get, results_url, query_params)\n Search::ResultsResponse.from(response)\n end\n rescue => e\n handle_error(e)\n end",
"def index... | [
"0.7627161",
"0.7400975",
"0.73309505",
"0.73102474",
"0.7303848",
"0.7197686",
"0.70246524",
"0.69998884",
"0.6963856",
"0.69354475",
"0.6914666",
"0.6851203",
"0.68335116",
"0.6798052",
"0.674726",
"0.67325014",
"0.6720427",
"0.66841894",
"0.66758746",
"0.6674328",
"0.66571... | 0.7027008 | 7 |
GET /results/1 GET /results/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(path, params = {}, opts = {})\n get(path, params, opts)['results']\n end",
"def index\n get_results\n end",
"def get_results\n\t\trace_id = params[:id]\n\t\t\n\t\trace = Race.find_by_id(race_id)\n\t\tresults = Result.get_race_results(race_id)\n\t\t\n\t\trender :json=>{:results=>results}\n\t... | [
"0.73266965",
"0.6979273",
"0.69192237",
"0.6817701",
"0.67208",
"0.6713047",
"0.6713047",
"0.66786873",
"0.66508305",
"0.66351783",
"0.66351783",
"0.66351783",
"0.66351783",
"0.6609092",
"0.66036445",
"0.65753514",
"0.6566137",
"0.64380974",
"0.6395807",
"0.63874984",
"0.638... | 0.0 | -1 |
PATCH/PUT /results/1 PATCH/PUT /results/1.json | def update
results = result_params
unless results.nil?
stay = true
if results.is_a?(String) #Update comes from online testing
parts = results.split("#")
labels = parts[0].split(",")
unless @result.nil?
@result.parse_csv(parts[1])
@result.parse_data(labels[1, labels.length-1], parts[2, parts.length-1]) if parts.length > 2
head 200
end
else
if results.has_key?("students") #Update comes from editing form
@measurement.update_students(results["students"])
else
results.each do |id, val|
r = @measurement.results.find_by_student_id(id)
unless r.nil?
if val.is_a?(String)
r.parse_csv(val)
stay = false
else
r.parse_Hash(val)
end
end
end
end
respond_to do |format|
format.js {
unless stay
render 'assessments/show'
else
render :edit
end
}
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @results = args[:results] if args.key?(:results)\n end",
"def update!(**args)\n @results = args[:results] if args.key?(:results)\n end",
"def update\n @result1 = Result1.find(params[:id])\n\n respond_to do |format|\n if @result1.update_attributes... | [
"0.6633545",
"0.6633545",
"0.65372896",
"0.6470854",
"0.6470854",
"0.6470854",
"0.6470854",
"0.64311457",
"0.6374878",
"0.6374878",
"0.6242018",
"0.62343436",
"0.622704",
"0.6226439",
"0.6225598",
"0.6221451",
"0.6221451",
"0.6221451",
"0.61800575",
"0.6157412",
"0.61360973",... | 0.60693043 | 26 |
Use callbacks to share common setup or constraints between actions. | def set_result
results = result_params
unless results.nil?
if results.is_a?(String)
parts = results.split("#")
@result = @measurement.results.find(parts[0].to_i)
end
end
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 result_params
params[:results]
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
GET /todoas GET /todoas.json | def index
@todoas = Todoa.where(user_id: current_user.id,done: false).order("due, created_at DESC")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n todo = Todo.find_by_id(params[:id])\n render json: todo.todos\n end",
"def index\n @to_dos = ToDo.all\n\n render json: @to_dos\n end",
"def show\n json_response(@todo)\n end",
"def index\n @todos = Todo.all\n render json: @todos\n end",
"def index\n ... | [
"0.74806",
"0.74517864",
"0.7390902",
"0.7323704",
"0.73077106",
"0.72355163",
"0.7201505",
"0.71214783",
"0.7115583",
"0.7069329",
"0.7020308",
"0.69641495",
"0.69641495",
"0.69447213",
"0.69446594",
"0.6943047",
"0.6926879",
"0.690439",
"0.6903333",
"0.6885049",
"0.6878017"... | 0.0 | -1 |
GET /todoas/today GET /todoas/1.json def show end GET /todoas/new | def new
@todo = Todo.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @todo = Todo.new\n @active_school_day = SchoolDay.find(params[:day]) unless params[:day].nil? || params[:day].empty?\n load_prev_and_next_day\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @todo }\n end\n end",
"def new\n @todo = Todo.n... | [
"0.7604947",
"0.7484157",
"0.7432773",
"0.73710805",
"0.7320951",
"0.7320951",
"0.7320951",
"0.7320951",
"0.7320951",
"0.7280585",
"0.72698146",
"0.7206616",
"0.71986496",
"0.71741474",
"0.71300066",
"0.71093225",
"0.70304585",
"0.7029657",
"0.6990824",
"0.6990824",
"0.698071... | 0.7022024 | 19 |
POST /todoas POST /todoas.json | def create
@todoa = Todoa.new(todoa_params)
@todoa.update_attribute(:user_id, current_user.id)
@todoa.update_attribute(:done, false)
respond_to do |format|
if @todoa.save
format.html { redirect_to todoas_url }
format.json { head :no_content }
else
format.html { render :new }
format.json { render json: @todoa.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @todo = Todo.create(todo_params)\n render json: @todo\n end",
"def create\n @to_do = ToDo.new(todo_params)\n\n if @to_do.save\n render json: @to_do, status: :created, location: @to_do\n else\n render json: @to_do.errors, status: :unprocessable_entity\n end\n e... | [
"0.7506411",
"0.7449141",
"0.74052006",
"0.7321971",
"0.7292871",
"0.72542304",
"0.71272767",
"0.71017945",
"0.70644575",
"0.70593596",
"0.70503014",
"0.70396084",
"0.69243747",
"0.69188446",
"0.6911885",
"0.6905172",
"0.69019246",
"0.69019246",
"0.69019246",
"0.6873174",
"0.... | 0.7080195 | 8 |
PATCH/PUT /todoas/1 PATCH/PUT /todoas/1.json | def update
respond_to do |format|
if @todoa.update(todoa_params)
format.html { redirect_to todoas_url }
format.json { render :show, status: :ok, location: @todoa }
else
format.html { render :edit }
format.json { render json: @todoa.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.... | [
"0.74879587",
"0.7331804",
"0.7228218",
"0.7188453",
"0.70345205",
"0.7003851",
"0.699332",
"0.69440234",
"0.693266",
"0.6846144",
"0.6829879",
"0.6829879",
"0.68144983",
"0.6802285",
"0.67872155",
"0.67872155",
"0.67615104",
"0.6726558",
"0.6689913",
"0.66807866",
"0.6680214... | 0.7050023 | 4 |
DELETE /todoas/1 DELETE /todoas/1.json | def destroy
@todoa.update_attribute(:done, true)
respond_to do |format|
format.html { redirect_to todoas_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @todo = Todo.find(params[:id])\n @todo.destroy\n render json: nil, status: :ok\n end",
"def destroy \n\n \n @todo = Todo.find(params[:id])\n @todo.destr... | [
"0.7966002",
"0.78061223",
"0.774923",
"0.7654915",
"0.7654915",
"0.76521724",
"0.76487494",
"0.7638106",
"0.76249874",
"0.7589164",
"0.75816894",
"0.75535804",
"0.75531095",
"0.7512754",
"0.7482195",
"0.74767554",
"0.7474563",
"0.74547684",
"0.74426115",
"0.7386858",
"0.7365... | 0.70944077 | 44 |
Within A Week filter: due | def week
@todoas = Todoa.where(user_id: current_user.id,done: false).where('due BETWEEN ? AND ?', Date.today, Date.today + 7.day)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def due?\n due_week == Date.today.cweek ? true : false\n end",
"def calc_weeks_till\n (calc_days_till / 7.0).round(2)\n end",
"def overdue\n schedules.where(:when.lte => Time.now)\n end",
"def is_grace_period?\n self.weekly_tasks.where(:is_weekly_payment_approved_by_cashier => true ).count... | [
"0.685636",
"0.63941085",
"0.6389732",
"0.6363789",
"0.628855",
"0.6245353",
"0.6210362",
"0.6079024",
"0.6077804",
"0.6074106",
"0.6048012",
"0.60396415",
"0.5979736",
"0.59346974",
"0.5927297",
"0.59237653",
"0.5919663",
"0.59169996",
"0.590989",
"0.58785534",
"0.58743626",... | 0.7100926 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_todoa
@todoa = Todoa.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 todoa_params
params.require(:todoa).permit(:content, :due)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
based on the total amount of the bill and the service. You need to consider the following ratings: Terrible: tip 0% Poor: tip 5% Good: tip 10% Great: tip 15% Excellent: tip 20% The rating is case insensitive. If an unrecognised rating is input, then you need to return: "Rating not recognised" in Javascript, Python and Ruby... ...or null in Java Because you're a nice person, you always round up the tip, regardless of the service. My solution | def calculate_tip(amount, rating)
return (amount * 0.00).ceil if rating.downcase == "terrible"
return (amount * 0.05).ceil if rating.downcase == "poor"
return (amount * 0.10).ceil if rating.downcase == "good"
return (amount * 0.15).ceil if rating.downcase == "great"
return (amount * 0.20).ceil if rating.downcase == "excellent"
'Rating not recognised'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_tip(amount, rating)\n rating = rating.downcase\n case\n when rating == \"terrible\"\n return 0\n when rating == \"poor\"\n return (amount * 0.05).ceil\n when rating == \"good\"\n return (amount * 0.10).ceil\n when rating == \"great\"\n return (amount * 0.15).ceil\n ... | [
"0.78396124",
"0.7637944",
"0.71468043",
"0.68900174",
"0.67414206",
"0.6583485",
"0.6484228",
"0.64826137",
"0.64732075",
"0.6470014",
"0.64441",
"0.64385456",
"0.6436402",
"0.63815796",
"0.6380034",
"0.6372914",
"0.6371688",
"0.633377",
"0.6285671",
"0.6231763",
"0.6220711"... | 0.78856295 | 0 |
Here's one of the best practices solutions that avoids a bit of the repatition that I have in my solution | def calculate_tip(amount, rating)
# A good use of a key/value hash (e.g. key == 'terrible' and value == 0) to minimize
# repetition of code
tips = { 'terrible' => 0, 'poor' => 0.05, 'good' => 0.1, 'great' => 0.15, 'excellent' => 0.2 }
return 'Rating not recognised' unless tips.keys.include? rating.downcase
# In this line the calculation is written only once using the keys/values of the hash 'tips'
(amount * tips[rating.downcase]).ceil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def anchored; end",
"def probers; end",
"def intensifier; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def generate_comprehensive\n\n end",
"def silly_adjective; end",
"def required_positionals; end",
"def off... | [
"0.61956215",
"0.57426524",
"0.56025034",
"0.54590654",
"0.52994776",
"0.52195454",
"0.52195454",
"0.52195454",
"0.52195454",
"0.5218055",
"0.51928675",
"0.5141854",
"0.51349646",
"0.5134731",
"0.5110873",
"0.5085573",
"0.5079585",
"0.5058764",
"0.50543374",
"0.5048721",
"0.5... | 0.0 | -1 |
========================================================= This is where you will write your code for the three phases | def put_new_lines(no_of_newlines)
no_of_newlines.times do
puts ""
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phase_three\n puts \"Phase 3 has been started\"\n\n 7.times do\n immune = @borneo.individual_immunity_challenge\n puts \"#{immune} wins the immunity\".blue\n\t\tvoted_off_contestant = @merge_tribe.tribal_council(immune: immune)\n\t\t@jury.add_member voted_off_contestant\n\t\tputs \"#{voted_off_contesta... | [
"0.638428",
"0.638248",
"0.6228562",
"0.62134427",
"0.62134427",
"0.61540085",
"0.61004066",
"0.60727775",
"0.6042017",
"0.5994848",
"0.594343",
"0.594343",
"0.5883013",
"0.5876965",
"0.58768505",
"0.58537185",
"0.5852844",
"0.5837563",
"0.580648",
"0.5804146",
"0.5793748",
... | 0.0 | -1 |
GET /controlqreats GET /controlqreats.json | def index
@controlqreats = Controlqreat.all
@controlqreatsb = Controlqreat.all.order(:vendida => :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_success: true,\n data: { chats: @chats }\n }\n end",
"def index\r\n @customerchats = Customerchat.all\r\n end",
"def... | [
"0.6293642",
"0.62649274",
"0.6227553",
"0.6217611",
"0.6217611",
"0.6217611",
"0.6217611",
"0.62148917",
"0.6198311",
"0.5984849",
"0.58845294",
"0.58760995",
"0.58565784",
"0.5746654",
"0.5740263",
"0.5715573",
"0.56944823",
"0.5620008",
"0.5590405",
"0.5562496",
"0.5524568... | 0.56067055 | 18 |
GET /controlqreats/1 GET /controlqreats/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end",
"def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_su... | [
"0.6073283",
"0.6069647",
"0.58769643",
"0.58176166",
"0.5813441",
"0.5813441",
"0.5813441",
"0.5813441",
"0.5806307",
"0.5717861",
"0.57111925",
"0.56459266",
"0.5575346",
"0.55734926",
"0.55301195",
"0.5528042",
"0.5524633",
"0.54899406",
"0.54899406",
"0.54870343",
"0.5484... | 0.0 | -1 |
POST /controlqreats POST /controlqreats.json | def create
@controlqreat = Controlqreat.new(controlqreat_params)
respond_to do |format|
if @controlqreat.save
format.html { redirect_to @controlqreat, notice: 'Controlqreat was successfully created.' }
format.json { render :show, status: :created, location: @controlqreat }
else
format.html { render :new }
format.json { render json: @controlqreat.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_success: true,\n data: { chats: @chats }\n }\n end",
"def create\n megam_rest.post_subscriptions(to_hash)\n ... | [
"0.52993083",
"0.5152659",
"0.49565074",
"0.49296808",
"0.48959574",
"0.4891538",
"0.4861037",
"0.4842285",
"0.48334873",
"0.47902018",
"0.47837582",
"0.47797003",
"0.47746673",
"0.47746673",
"0.47746673",
"0.47746673",
"0.47553334",
"0.47144556",
"0.46994928",
"0.46954262",
... | 0.5409968 | 0 |
PATCH/PUT /controlqreats/1 PATCH/PUT /controlqreats/1.json | def update
respond_to do |format|
if @controlqreat.update(controlqreat_params)
format.html { redirect_to @controlqreat, notice: 'Controlqreat was successfully updated.' }
format.json { render :show, status: :ok, location: @controlqreat }
else
format.html { render :edit }
format.json { render json: @controlqreat.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @reactive.update(reactive_params)\n format.html { redirect_to @reactive, notice: 'Reactive was successfully updated.' }\n format.json { render :show, status: :ok, location: @reactive }\n else\n format.html { render :edit }\n format.j... | [
"0.59039277",
"0.5684318",
"0.5649839",
"0.5645795",
"0.5624456",
"0.561777",
"0.5592359",
"0.5559289",
"0.5549457",
"0.55223876",
"0.5502797",
"0.54995275",
"0.54957056",
"0.5495548",
"0.5493636",
"0.54930747",
"0.5492069",
"0.54907864",
"0.5482993",
"0.54730076",
"0.546899"... | 0.59634584 | 0 |
DELETE /controlqreats/1 DELETE /controlqreats/1.json | def destroy
@controlqreat.destroy
respond_to do |format|
format.html { redirect_to controlqreats_url, notice: 'Controlqreat was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\",... | [
"0.6928654",
"0.67513686",
"0.6438945",
"0.64277744",
"0.6417723",
"0.64145696",
"0.6410609",
"0.639966",
"0.6398458",
"0.63765",
"0.6356237",
"0.6356112",
"0.63547003",
"0.63373053",
"0.6302653",
"0.63002825",
"0.62984616",
"0.6298148",
"0.6296105",
"0.6292777",
"0.62882495"... | 0.70011955 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_controlqreat
@controlqreat = Controlqreat.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 controlqreat_params
params.require(:controlqreat).permit(:numero, :limite, :vendida)
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 |
Assitant methods used for partial display of an individual student | def get_upcoming_by_student
@user = get_user()
student = verify_student_teacher_relationship(params[:id])
unless student == false
@lessons = student.get_upcoming_lessons
unless student.nil?
unless @lessons.nil? || @lessons.count == 0
respond_to do |format|
format.js { render "student_upcoming_individual", :layout => false, :status => :ok }
format.html { redirect_to root_path }
end
else
respond_to do |format|
format.js { render :text=>"No upcoming lesson", :layout => false, :status => :ok }
format.html { redirect_to root_path }
end
end
else
redirect_to root_path
end
else
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def student_displayer\n print_header\n print_students_list\n print_footer\nend",
"def show_students\n print_header\n print_student_list\n print_footer\nend",
"def show_students\n print_header\n print_student_list\n print_footer\nend",
"def show_students\n print_header\n print_students_list\n ... | [
"0.7276209",
"0.71485347",
"0.71485347",
"0.7115031",
"0.70967686",
"0.70967686",
"0.70967686",
"0.7095281",
"0.7048756",
"0.6971372",
"0.6931754",
"0.67799187",
"0.6756236",
"0.672007",
"0.67100406",
"0.67039317",
"0.67001784",
"0.6693662",
"0.66916484",
"0.66894364",
"0.668... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def lesson_params
params.require(:lesson).permit(:student_id, :paid, :updated_at, :schedule, :log, :resolved)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Used by page preview iframe in Pageedit view. | def show
@preview_mode = true
@root_page = Page.language_root_for(session[:language_id])
# Setting the locale to pages language. so the page content has its correct translation
::I18n.locale = @page.language_code
render :layout => layout_for_page
rescue Exception => e
exception_logger(e)
render :file => Rails.root.join('public', '500.html'), :status => 500, :layout => false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iframe\n end",
"def content_preview\n self.send(content_preview_method)\n end",
"def preview\n end",
"def preview\n end",
"def _remove_iframe_edit()\n @parent.render(partial: 'dc_common/iframe_edit', formats: [:html])\nend",
"def iframes; end",
"def edit_page\n self.back_to_top\n edit... | [
"0.6949945",
"0.672179",
"0.6678368",
"0.6678368",
"0.65359885",
"0.6511137",
"0.65089613",
"0.64920044",
"0.6425153",
"0.6385652",
"0.6356663",
"0.6345815",
"0.6224425",
"0.61835825",
"0.61829937",
"0.618129",
"0.6163839",
"0.6140604",
"0.61383027",
"0.61145735",
"0.61145735... | 0.0 | -1 |
Edit the content of the page and all its elements and contents. | def edit
# fetching page via before filter
if page_is_locked?
flash[:notice] = _t("This page is locked by %{name}", name: @page.locker_name)
redirect_to admin_pages_path
else
@page.lock!(current_alchemy_user)
@locked_pages = Page.from_current_site.all_locked_by(current_alchemy_user)
end
@layoutpage = @page.layoutpage?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n # Clear the page cache for this page... ?\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n @page.update_attributes(params[:page])\n @page.updated_on = Time.now\n @page.author = current_user\n if @page.valid? && @page.save\n exp... | [
"0.7460927",
"0.7353309",
"0.72742045",
"0.723043",
"0.7183251",
"0.7015001",
"0.67863077",
"0.67813516",
"0.6683217",
"0.6646017",
"0.6615467",
"0.6587621",
"0.65855056",
"0.657112",
"0.6543015",
"0.65103585",
"0.6503915",
"0.64989746",
"0.6495359",
"0.647173",
"0.6452909",
... | 0.6409728 | 24 |
Set page configuration like page names, meta tags and states. | def configure
# fetching page via before filter
if @page.redirects_to_external?
render action: 'configure_external', layout: !request.xhr?
else
@page_layouts = PageLayout.layouts_with_own_for_select(@page.page_layout, session[:language_id], @page.layoutpage?)
render layout: !request.xhr?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_page_data\n @page_title = \"Dragos | My Portfolio\"\n @seo_keywords = \"Dragos Portfolio\"\n end",
"def set_page\n end",
"def set_page_defaults\n @site_defaults = SiteConfiguration.all\n @page_title ||= 'Aeromotion Pages'\n @seo_keywords ||= 'Aeromotion, Tutorials, Workouts, Best Tra... | [
"0.70612043",
"0.7015111",
"0.6942616",
"0.68787104",
"0.67413145",
"0.6512817",
"0.63669056",
"0.63343114",
"0.63134557",
"0.63127756",
"0.6232192",
"0.6216869",
"0.61988807",
"0.61858875",
"0.6179763",
"0.61720645",
"0.615617",
"0.61314374",
"0.6104321",
"0.60811013",
"0.60... | 0.5995688 | 81 |
Leaves the page editing mode and unlocks the page for other users | def unlock
# fetching page via before filter
@page.unlock!
flash[:notice] = _t(:unlocked_page, :name => @page.name)
@pages_locked_by_user = Page.from_current_site.all_locked_by(current_alchemy_user)
respond_to do |format|
format.js
format.html {
redirect_to params[:redirect_to].blank? ? admin_pages_path : params[:redirect_to]
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unlock\n # fetching page via before filter\n @page.unlock\n flash[:notice] = _(\"unlocked_page_%{name}\") % {:name => @page.name}\n if params[:redirect_to].blank?\n redirect_to admin_pages_path\n else\n redirect_to(params[:redirect_to])\n end\n end",
"def edit\n # fetching... | [
"0.72298294",
"0.7103706",
"0.6736628",
"0.65873295",
"0.64931464",
"0.6491493",
"0.6458248",
"0.631359",
"0.6263636",
"0.61939573",
"0.6162504",
"0.6122239",
"0.6121755",
"0.6089339",
"0.60314757",
"0.60039335",
"0.59662956",
"0.59481436",
"0.5943078",
"0.5874733",
"0.585737... | 0.7250431 | 0 |
Sets the page public and sweeps the page cache | def publish
# fetching page via before filter
@page.publish!
flash[:notice] = _t(:page_published, :name => @page.name)
redirect_back_or_to_default(admin_pages_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def become_public\n page.touch(:published_at)\n activate!\n end",
"def set_page_caching_status\n @page_caching_active = page_caching_active\n end",
"def set_private\n response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'\n end",
"def main= page\n @cache[:main]... | [
"0.7148789",
"0.6577298",
"0.64943403",
"0.639704",
"0.6367284",
"0.6256826",
"0.6227471",
"0.6171897",
"0.6075969",
"0.60728693",
"0.6061831",
"0.6025381",
"0.6005819",
"0.59848607",
"0.59831786",
"0.59677833",
"0.59660214",
"0.5949717",
"0.59471583",
"0.5907433",
"0.5894409... | 0.55564594 | 72 |
Receives a JSON object representing a language tree to be ordered and updates all pages in that language structure to their correct indexes | def order
neworder = JSON.parse(params[:set])
rootpage = Page.language_root_for(session[:language_id])
tree = create_tree(neworder, rootpage)
Alchemy::Page.transaction do
tree.each do |key, node|
dbitem = Page.find(key)
dbitem.update_node!(node)
end
end
flash[:notice] = _t("Pages order saved")
@redirect_url = admin_pages_path
render :action => :redirect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_pages\n params[:page].each_with_index {|val, index|\n obj = Page.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def reorganize\n list = params[:list]\n prev_page = nil\n last_root = nil\n list.each_with_index do |item, i... | [
"0.6220755",
"0.61285365",
"0.58972394",
"0.58962286",
"0.58866996",
"0.58540565",
"0.58212966",
"0.5708119",
"0.56878644",
"0.5685896",
"0.5670505",
"0.56249523",
"0.55592084",
"0.5553623",
"0.5505358",
"0.53920597",
"0.53111446",
"0.52918154",
"0.52825683",
"0.5206314",
"0.... | 0.67571056 | 0 |
Returns the current left index and the aggregated hash of tree nodes indexed by page id visited so far Visits a batch of children nodes, assigns them the correct ordering indexes and spuns recursively the same procedure on their children, if any | def visit_nodes(nodes, my_left, parent, depth, tree, url, restricted)
nodes.each do |item|
my_right = my_left + 1
my_restricted = item['restricted'] || restricted
urls = process_url(url, item)
if item['children']
my_right, tree = visit_nodes(item['children'], my_left + 1, item['id'], depth + 1, tree, urls[:children_path], my_restricted)
end
tree[item['id']] = TreeNode.new(my_left, my_right, parent, depth, urls[:my_urlname], my_restricted)
my_left = my_right + 1
end
[my_left, tree]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freshen_parent_and_child_indexes\n freshen_parent_and_child_indexes(0)\n end",
"def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = r.calc_numbers(n, indexes)\n end\n ... | [
"0.6585421",
"0.6296762",
"0.62734157",
"0.6149055",
"0.60687774",
"0.59753585",
"0.59052163",
"0.5891231",
"0.58688504",
"0.5868525",
"0.57712144",
"0.575766",
"0.57324445",
"0.5721029",
"0.5699342",
"0.5694033",
"0.5658218",
"0.56391335",
"0.5633562",
"0.56327724",
"0.56013... | 0.0 | -1 |
Returns a Hash of TreeNode's indexed by their page ids Grabs the array representing a tree structure of pages passed as a parameter, visits it and creates a map of TreeNodes indexed by page id featuring Nested Set ordering information consisting of the left, right, depth and parent_id indexes as well as a node's url and restricted status | def create_tree(items, rootpage)
_, tree = visit_nodes(items, rootpage.lft + 1, rootpage.id, rootpage.depth + 1, {}, "", rootpage.restricted)
tree
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_tree\n @tree ||= [self.root_page.tree_hash_value]\n @tree\n end",
"def tree_list(ref)\n sha = @access.ref_to_sha(ref)\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n next list unless @page_class.valid_page_name?(entry.name)\n list <... | [
"0.6766414",
"0.67059916",
"0.66228086",
"0.6402833",
"0.63840026",
"0.6301937",
"0.6272078",
"0.6252339",
"0.62197626",
"0.6202627",
"0.6202627",
"0.6149146",
"0.6120295",
"0.6092374",
"0.6092218",
"0.59475094",
"0.59475094",
"0.5926859",
"0.5925275",
"0.5893911",
"0.5855868... | 0.5625126 | 27 |
Returns a pair, the path that a given tree node should take, and the path its children should take This function will add a node's own slug into their ancestor's path in order to create the full URL of a node NOTE: external and invisible pages are not part of the full path of their children | def process_url(ancestors_path, item)
default_urlname = (ancestors_path.blank? ? "" : "#{ancestors_path}/") + item['slug'].to_s
pair = {my_urlname: default_urlname, children_path: default_urlname}
if item['external'] == true || item['visible'] == false
# children ignore an ancestor in their path if external or invisible
pair[:children_path] = ancestors_path
end
pair
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n\t\t\"/\" + parents.reverse.map(&:slug).join(\"/\")\n\tend",
"def build_path\n _pages = self.parents.reverse + [self]\n self.path = _pages.map(&:slug).reject(&:blank?).join('/')\n end",
"def path_to_root\n parent.nil? ? [slug] : parent.path_to_root.push(slug)\n end",
"def set_path\n... | [
"0.74903286",
"0.70413107",
"0.6924038",
"0.671587",
"0.6636282",
"0.6634601",
"0.6439336",
"0.64261365",
"0.63258934",
"0.6032507",
"0.6029984",
"0.6022621",
"0.60150933",
"0.5981849",
"0.59657985",
"0.5924513",
"0.5924513",
"0.5856206",
"0.5841519",
"0.5766566",
"0.5766566"... | 0.6489645 | 6 |
=============================================================================== The names of each pocket of the Bag. Leave the first entry blank. The maximum number of slots per pocket (1 means infinite number). Ignore the first number (0). The maximum number of items each slot in the Bag can hold. Whether each pocket in turn autosorts itself by item ID number. Ignore the first entry (the 0). =============================================================================== | def pbPocketNames; return ["",
_INTL("Items"),
_INTL("Medicine"),
_INTL("Jermo Balls"),
_INTL("TMs & HMs"),
_INTL("Bewwies"),
_INTL("Mail"),
_INTL("Battle Items"),
_INTL("Key Items")
]; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def brief_inventory\n self.seed_bag_count_hash(0).each do |crop_name, amount|\n puts \"#{crop_name}\".upcase.bold + \" x#{amount}\"\n end\n #=> TURNIP x4\n #=> TOMATO x1\n end",
"def pack_size_names\n return @pack_size_names if @pack_size_names\n names = @lines.inject([]) { |arr, l| a... | [
"0.6062747",
"0.5997083",
"0.5593323",
"0.55784065",
"0.5383438",
"0.5376058",
"0.53467584",
"0.53321767",
"0.5330999",
"0.5262275",
"0.52269137",
"0.52166253",
"0.5209296",
"0.5179613",
"0.516168",
"0.51499915",
"0.51476187",
"0.5137705",
"0.5099647",
"0.5090656",
"0.5085918... | 0.58513564 | 2 |
=============================================================================== The name of the person who created the Jermon storage system. The number of boxes in Jermon storage. =============================================================================== | def pbStorageCreator
return _INTL("The Jermon Team")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n return TUTOR_BOX_COUNT if type == \"tutor_table\"\n @boxes.nil? ? 0 : @boxes.count\n end",
"def item_count()\n @names.count\n end",
"def name;\n \"#{@type}.#{@size}\"\n end",
"def head_count1\n return @room1_guests.count()\n end",
"def number_of_guests\n guests_count = ... | [
"0.5948798",
"0.5929389",
"0.591083",
"0.590452",
"0.58967876",
"0.5887325",
"0.56644654",
"0.56200624",
"0.5606192",
"0.5594161",
"0.558389",
"0.5510334",
"0.54990274",
"0.5492771",
"0.5492259",
"0.54808956",
"0.54803616",
"0.54665685",
"0.54664725",
"0.5448812",
"0.5406907"... | 0.0 | -1 |
Reading nonexisting file causes segfault on file.read | def check_exists
raise GlusterFS::Error, "File does not exist: #{@path}" unless exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read\n File.read(file_name)\n rescue Errno::ENOENT\n # ignore, will return nil\n end",
"def do_file_read(f)\n File.read(f) rescue(bail \"File Read Error: #{$!}\")\n end",
"def valid_read_file!(file)\n raise IOError, \"Unable to read #{file}\" unless File.file?(file) and File.readable... | [
"0.715822",
"0.69395596",
"0.6756",
"0.67050326",
"0.6688566",
"0.6664959",
"0.6646413",
"0.6587537",
"0.6587537",
"0.6528403",
"0.64459264",
"0.64092606",
"0.6380194",
"0.6351274",
"0.6319189",
"0.630465",
"0.630465",
"0.6289736",
"0.6289736",
"0.62695855",
"0.6268256",
"0... | 0.0 | -1 |
read first line for Top Right Coordinates | def handle_top_right_coords_instruction(file)
line_reader = self.read_instruction_line(file, " ")
self.set_up_right_coordinates(line_reader)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_line\n line_from_ip(0)\n end",
"def first_line_in_view()\n\t\tcoord_to_line_num(contents_y)\n\tend",
"def read_header\n @ch = case STDIN.readline.chomp\n when \"P5\" then 1\n when \"P6\" then 3\n else 0\n end\n while (sz0 = STDIN.readline) =~ /^#/ do\n end\n sz = sz0.chomp.split\n @... | [
"0.64102584",
"0.63687587",
"0.6288314",
"0.6129006",
"0.6040347",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.6031029",
"0.59302115",
"0.5867581",
"0.5810417",
"0.58063304",
"0.577323",
"0.5760625",
... | 0.6703143 | 0 |
read line for Rover Position | def handle_rover_position_instruction(file)
line_reader = self.read_instruction_line(file, " ")
self.set_rover_start_coordinates(line_reader)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readline\n end",
"def read\n @lines.shift\n end",
"def read\n @index += 1\n line = @last ? @last : @lines[@index]\n @last = nil\n line\n end",
"def read_line\n @line = @file.gets\n @file.close if @line.nil?\n end",
"def readline(p); Readline.readline(p); end",
"def re... | [
"0.662174",
"0.6359417",
"0.623647",
"0.62186366",
"0.61948186",
"0.61487454",
"0.6122554",
"0.60518664",
"0.60518664",
"0.60518664",
"0.6034611",
"0.60201263",
"0.6016032",
"0.6016032",
"0.59902537",
"0.5973269",
"0.59312445",
"0.5827841",
"0.5794362",
"0.5783132",
"0.576962... | 0.69195426 | 0 |
If spin_direction is left then left_spin_heading value will be evaluated or if spin_direction is right then right_spin_heading will evaluated i.e. Left Turn from N or Right Turn from S results in W | def evaluate_spin(spin_direction,left_spin_heading, right_spin_heading)
@heading == left_spin_heading && spin_direction == "left" ||
@heading == right_spin_heading && spin_direction == "right"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_left\n case @heading\n when 'W' then @heading = 'S'\n when 'E' then @heading = 'N'\n when 'N' then @heading = 'W'\n when 'S' then @heading = 'E'\n end\n end",
"def spin\r\n\t\t\t\t\t\t\t@spin_flag = true\r\n\t\t\t\t\t\t\t@spin_counter+=1\r\n\t\t\t\t\t\t\t@reward = @wheel[get_wheel_rew... | [
"0.68569785",
"0.66276467",
"0.64808726",
"0.6478553",
"0.64484185",
"0.64399874",
"0.64168173",
"0.6309339",
"0.6278862",
"0.6206079",
"0.619083",
"0.6084233",
"0.6084233",
"0.60624236",
"0.60592306",
"0.59688103",
"0.58941597",
"0.58324736",
"0.58223385",
"0.5822083",
"0.58... | 0.8042469 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.