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 |
|---|---|---|---|---|---|---|
reply no match message | def reply_no_match(event)
return if bot_node.exception_text.blank?
template = []
template << {
"type": "text",
"text": bot_node.exception_text.gsub(%r{</?[^>]+?>}, "")
}
template << site_search(event) if site_search?
client.reply_message(event["replyToken"], template)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reply\n end",
"def should_reply?(params)\n !$redis.exists?('snarkov:shush') &&\n (settings.ignore_regex.nil? || !params[:text].match(settings.ignore_regex)) &&\n (rand <= ENV['RESPONSE_CHANCE'].to_f || (!settings.reply_regex.nil? && params[:text].match(settings.reply_regex)))\nend",
"def test_create_re... | [
"0.6704406",
"0.66692793",
"0.64100426",
"0.6394903",
"0.6357938",
"0.6322856",
"0.62398183",
"0.62103385",
"0.6187165",
"0.6173946",
"0.6144172",
"0.6086556",
"0.6071918",
"0.60665345",
"0.60661805",
"0.60422885",
"0.6027966",
"0.60227364",
"0.60029376",
"0.59898376",
"0.596... | 0.6945222 | 0 |
Logs the request if needed. | def call(env)
if WialonApi.log_requests?
@logger.debug "#{env[:method].to_s.upcase} #{env[:url]}"
@logger.debug "body: #{env[:body].inspect}" unless env[:method] == :get
end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_log(request); end",
"def log_request\n logger.info \"HTTP request received => #{request.fullpath} , params => #{params} \"\n end",
"def log_request\n # REQUEST_LOG.info( {\n # time: Time.now.to_s,\n # ip: request.remote_ip,\n # path: ... | [
"0.8101725",
"0.7743363",
"0.7448667",
"0.74329317",
"0.7344709",
"0.7340635",
"0.73355925",
"0.73193973",
"0.7128285",
"0.71130466",
"0.70587224",
"0.6952697",
"0.68859017",
"0.68692523",
"0.6866476",
"0.6769208",
"0.675615",
"0.6749367",
"0.6731268",
"0.66947377",
"0.668361... | 0.0 | -1 |
Logs the response (successful or not) if needed. | def on_complete(env)
if env[:body].respond_to?(:error) && env[:body].error?
@logger.warn env[:raw_body] if WialonApi.log_errors?
else
@logger.debug env[:raw_body] if WialonApi.log_responses?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_response\n log \"SOAP response (status #{@response.code}):\"\n log @response.body\n end",
"def log_response response\n if config.logger\n message = config.log_formatter.format(response)\n config.logger.send(config.log_level, message)\n end\n nil\n ... | [
"0.75211626",
"0.7188595",
"0.70126253",
"0.6682813",
"0.6643926",
"0.65983593",
"0.65465885",
"0.64669555",
"0.63845766",
"0.634385",
"0.6289718",
"0.62635607",
"0.62550133",
"0.6231753",
"0.6149692",
"0.6140979",
"0.6139869",
"0.61225337",
"0.6118132",
"0.61022526",
"0.6091... | 0.57147294 | 69 |
This patch is provided by the original authors of this software | def patches
{ :p0 => "http://www.thc.org/thc-hydra/hydra-6.5-fix.diff" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch; end",
"def patch; end",
"def private; end",
"def patch_version; end",
"def patch=(_arg0); end",
"def patches\n \"https://gist.github.com/fredrikw/5858168/raw\"\n end",
"def original; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal(... | [
"0.7495742",
"0.7495742",
"0.74207604",
"0.701181",
"0.67523146",
"0.66403925",
"0.6562028",
"0.6455914",
"0.6455914",
"0.6455914",
"0.6455914",
"0.63792384",
"0.63757914",
"0.63722456",
"0.63258886",
"0.6325326",
"0.6325326",
"0.62070006",
"0.62070006",
"0.6168028",
"0.61443... | 0.0 | -1 |
Merge changes from the client into the target has_many relation | def merge_many_changes( target_class, foreign_key, original_list, proposed_list )
proposed_list = [] if proposed_list.nil?
deleted_items = original_list.map { |item| item.id }
proposed_list.each { |proposed_item|
if proposed_item[:id].nil?
# add place
proposed_item[foreign_key] = self.id
item = target_class.new(proposed_item)
item.save
else
# update place
item = target_class.where("id = ? and #{foreign_key} = ?", proposed_item[:id], self.id ).first
unless item.nil?
item.update(proposed_item)
deleted_items.delete(item.id)
item.save
end
end
}
# delete items not found in the proposed list
target_class.destroy(deleted_items)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_into(target)\n target_id = target.id\n # Find all the Entries attached to this name, that will need to be\n # reindexed after the merge\n entry_ids = entry_ids_to_index_on_update\n\n ids = EntryArtist.where(artist_id: self.id).pluck(:id)\n EntryArtist.where(artist_id: self.id).update_al... | [
"0.6279769",
"0.604382",
"0.5891735",
"0.582994",
"0.58014786",
"0.57531184",
"0.57325864",
"0.56632537",
"0.5641926",
"0.56298",
"0.5607323",
"0.55446535",
"0.5533901",
"0.5524569",
"0.5494175",
"0.5429972",
"0.5389573",
"0.53818464",
"0.53704613",
"0.5345588",
"0.53173304",... | 0.680091 | 0 |
GET /receipt_states GET /receipt_states.json | def index
@receipt_states = ReceiptState.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def show\n \n @states = State.find(:all)\n @state ... | [
"0.69379455",
"0.6857879",
"0.65066457",
"0.648242",
"0.64304185",
"0.632138",
"0.62439007",
"0.6206591",
"0.61973417",
"0.61973417",
"0.61973417",
"0.61973417",
"0.61973417",
"0.6164506",
"0.6146889",
"0.60967326",
"0.6074763",
"0.60676855",
"0.6046754",
"0.6041937",
"0.6041... | 0.78011894 | 0 |
GET /receipt_states/1 GET /receipt_states/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @receipt_states = ReceiptState.all\n end",
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def index\n @states = State.all\n \n render json: @states\n end",
"def sh... | [
"0.7518266",
"0.72151774",
"0.65934783",
"0.6524527",
"0.6524462",
"0.6524462",
"0.64398336",
"0.6361585",
"0.6247348",
"0.6233903",
"0.62020814",
"0.61944073",
"0.61319196",
"0.6127227",
"0.61244375",
"0.6119571",
"0.61108017",
"0.61108017",
"0.61108017",
"0.61108017",
"0.61... | 0.0 | -1 |
POST /receipt_states POST /receipt_states.json | def create
@receipt_state = ReceiptState.new(receipt_state_params)
respond_to do |format|
if @receipt_state.save
format.html { redirect_to @receipt_state, notice: 'Receipt state was successfully created.' }
format.json { render :show, status: :created, location: @receipt_state }
else
format.html { render :new }
format.json { render json: @receipt_state.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @receipt_states = ReceiptState.all\n end",
"def receipt_state_params\n params.require(:receipt_state).permit(:nombre_stado)\n end",
"def create\n @state = State.new(state_params)\n\n if @state.save\n render json: @state, status: :created, location: @state\n # 'state was ... | [
"0.649192",
"0.63740605",
"0.6246726",
"0.61306775",
"0.6122478",
"0.61122656",
"0.6104916",
"0.60867023",
"0.60867023",
"0.6065897",
"0.60073394",
"0.6000724",
"0.59957796",
"0.59414953",
"0.5928737",
"0.5911682",
"0.58995104",
"0.58942944",
"0.58910877",
"0.5888117",
"0.588... | 0.7340731 | 0 |
PATCH/PUT /receipt_states/1 PATCH/PUT /receipt_states/1.json | def update
respond_to do |format|
if @receipt_state.update(receipt_state_params)
format.html { redirect_to @receipt_state, notice: 'Receipt state was successfully updated.' }
format.json { render :show, status: :ok, location: @receipt_state }
else
format.html { render :edit }
format.json { render json: @receipt_state.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @state.update(state_params)\n render json: @state\n # 'State was successfully updated.'\n else\n render json: @state.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @state.update(state_params)\n format.html { re... | [
"0.63248605",
"0.6306019",
"0.6288814",
"0.6217703",
"0.6190923",
"0.6190923",
"0.6190923",
"0.61779803",
"0.61779803",
"0.6172729",
"0.61595523",
"0.6146655",
"0.60489464",
"0.6044657",
"0.6022419",
"0.60206044",
"0.60142106",
"0.60083175",
"0.5993382",
"0.5981407",
"0.59766... | 0.7177747 | 0 |
DELETE /receipt_states/1 DELETE /receipt_states/1.json | def destroy
@receipt_state.destroy
respond_to do |format|
format.html { redirect_to receipt_states_url, notice: 'Receipt state was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to states_url }\n ... | [
"0.70470834",
"0.7008135",
"0.7008135",
"0.6873279",
"0.6834429",
"0.68301964",
"0.68301964",
"0.68074685",
"0.68043023",
"0.67960346",
"0.67337346",
"0.67021126",
"0.66827655",
"0.66757196",
"0.66734725",
"0.6652055",
"0.66333133",
"0.6571744",
"0.6561338",
"0.6556591",
"0.6... | 0.75771815 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_receipt_state
@receipt_state = ReceiptState.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def receipt_state_params
params.require(:receipt_state).permit(:nombre_stado)
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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
GET /reviews/1 GET /reviews/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end",
"def index\n @reviews = Review.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reviews }\n en... | [
"0.78802043",
"0.7516337",
"0.7516337",
"0.75039405",
"0.7391449",
"0.73524773",
"0.73433435",
"0.73430485",
"0.73315936",
"0.73315936",
"0.7282209",
"0.71597594",
"0.7129899",
"0.7129899",
"0.7129899",
"0.7129899",
"0.7129899",
"0.7087675",
"0.70691717",
"0.70653343",
"0.705... | 0.0 | -1 |
POST /reviews POST /reviews.json | def create
@note = Note.new(note_params)
respond_to do |format|
if @note.save
format.html { redirect_to stock_path(params[])}
format.json { render :show, status: :created, location: @note }
else
format.html { render :new }
format.json { render json: @note.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @review = current_author.reviews.create(review_params)\n render json: @review, status: 201\n end",
"def create\n review = course.reviews.new(review_params)\n \n if review.save\n render json: ReviewSerializer.new(review).serialized_json\n else\n render... | [
"0.7576602",
"0.75637454",
"0.7493771",
"0.747111",
"0.747111",
"0.747111",
"0.7300367",
"0.72989565",
"0.7201945",
"0.7201945",
"0.71795744",
"0.717838",
"0.71406734",
"0.7120858",
"0.7118763",
"0.7002209",
"0.6988962",
"0.6979939",
"0.69722533",
"0.69606304",
"0.6958055",
... | 0.0 | -1 |
PATCH/PUT /reviews/1 PATCH/PUT /reviews/1.json | def update
respond_to do |format|
if @note.update(note_params)
format.html { redirect_to @note}
format.json { render :show, status: :ok, location: @note }
else
format.html { render :edit }
format.json { render json: @note.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @review = Review.find(params[:id])\n @review.update(review_params)\n render json: @review\n end",
"def update\n @review = reviewable.reviews.find(params[:id])\n\n respond_to do |format|\n if @review.update_attributes(params[:review])\n format.html { redirect_to reviewable... | [
"0.7438452",
"0.70832837",
"0.70328504",
"0.70328504",
"0.70328504",
"0.69496596",
"0.6926178",
"0.69167197",
"0.69167197",
"0.69167197",
"0.69167197",
"0.6888808",
"0.6832852",
"0.6780394",
"0.6780394",
"0.6780394",
"0.6735564",
"0.67207444",
"0.67168",
"0.67168",
"0.67168",... | 0.0 | -1 |
DELETE /reviews/1 DELETE /reviews/1.json | def destroy
@note.destroy
respond_to do |format|
format.html { redirect_to notes_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reviews_delete(id)\n delete id.to_s\n _response_status(204, last_response)\n end",
"def destroy\n @review = reviewable.reviews.find(params[:id])\n @review.destroy\n\n respond_to do |format|\n format.html { redirect_to reviewable_reviews_url(reviewable) }\n format.json { head :no_co... | [
"0.7832836",
"0.7792274",
"0.77834046",
"0.77717566",
"0.77717566",
"0.77717566",
"0.77717566",
"0.77717566",
"0.7675156",
"0.7674345",
"0.7652286",
"0.7652286",
"0.7652286",
"0.7639822",
"0.74985015",
"0.74985015",
"0.7471254",
"0.7412546",
"0.7410434",
"0.7410434",
"0.74104... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_note
@note = Note.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def note_params
params.require(:note).permit(:comment, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
cell with multiple nodes is represented as singlecolumn table | def cell_table(cell, width, style_options)
data = cell.nodes.map { |n| [normalize_cell_node(n, width, style_options)] }
pdf.make_table(data,
width: width,
cell_style: {
padding: [0, 0, 0, 0],
borders: [],
border_width: 0,
inline_format: true
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _node_parse_table_cell(node)\n # In a Swordfish::Node::Table object, the number of table cells must equal the\n # total number of rows times the total number of columns; that is, even if\n # two cells are merged together, there must be a Swordfish::Node::TableCell for\n # each one. ... | [
"0.71189755",
"0.6335158",
"0.632168",
"0.61995035",
"0.6161802",
"0.6108293",
"0.60842776",
"0.6019744",
"0.6016464",
"0.59983504",
"0.599295",
"0.5964404",
"0.5953297",
"0.59496063",
"0.59333026",
"0.5929688",
"0.59242576",
"0.5920149",
"0.59186566",
"0.5917206",
"0.5853581... | 0.68957233 | 1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.notice_mailer.sendmail_confirm.subject | def sendmail_confirm(user)
@user = user
mail(to: user.email,
subject: "会計よりお知らせ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end",
"def message_subject=(value)\n ... | [
"0.6913642",
"0.68215305",
"0.67956865",
"0.6684918",
"0.66837823",
"0.6679666",
"0.6677335",
"0.6580134",
"0.65671325",
"0.6547826",
"0.64369136",
"0.6429522",
"0.6425408",
"0.63602126",
"0.6349901",
"0.6337199",
"0.6332632",
"0.6322143",
"0.62865",
"0.6223848",
"0.61906713"... | 0.0 | -1 |
input: output: Steps 1 2 3 Commit 2 Initial Solution | def daffify(message)
# write code here
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def steps\n find_solution\n end",
"def solution4(input)\n end",
"def testCommitments_case0\n c1 = ''\n d1 = ''\n a1 = ''\n c2 = ''\n d2 = ''\n a2 = ''\n c3 = ''\n d3 = ''\n a3 = ''\n c4 = ''\n d4 = ''\n a4 = ''\n c5 = ''\n d5 = ''\n a5 = ''\n c6 = ''\n d6 = ''\n a6 = ''\n c7 = ''\n d7 ... | [
"0.6290672",
"0.62173474",
"0.5873614",
"0.5618567",
"0.55538255",
"0.5520001",
"0.5497463",
"0.5491631",
"0.54683095",
"0.54658955",
"0.53777206",
"0.5376906",
"0.5370618",
"0.5365146",
"0.5355532",
"0.53511",
"0.53492326",
"0.53184116",
"0.5295605",
"0.5273225",
"0.5271605"... | 0.0 | -1 |
Use the array's native insert method | def insert(element)
if @ary.include? element
return false
else
@ary << element
return element
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def using_insert(array, element)\n array.insert(4,element)\nend",
"def using_insert(array,element)\n array.insert(4,element)\nend",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def using_insert(array, element)\n array.insert(4, element)\nend",
"def using_insert(array, element)... | [
"0.83433336",
"0.83423513",
"0.8329462",
"0.8329462",
"0.8329462",
"0.8329462",
"0.8329462",
"0.83247113",
"0.83023584",
"0.8230463",
"0.82256",
"0.8193648",
"0.8189784",
"0.8056227",
"0.7931485",
"0.7851081",
"0.7523291",
"0.73973036",
"0.7380108",
"0.73222804",
"0.7195992",... | 0.6455882 | 43 |
Use the array's native include method | def include?(element)
@ary.include? element
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def using_include(array, element)\n\tarray.include?(element)\nend",
"def includes(*args)\n @options[:include] ||= []\n @options[:include] |= args\n end",
"def include(*args)\n include_or_extend(:include, *args)\n end",
"def include? array, item\n array.include?(item)\nend",
... | [
"0.8226738",
"0.726154",
"0.7227126",
"0.7145582",
"0.71411514",
"0.7136233",
"0.7136233",
"0.7124808",
"0.70020485",
"0.69860375",
"0.69860035",
"0.6983733",
"0.6928293",
"0.69255954",
"0.6866376",
"0.6859661",
"0.68410623",
"0.68348384",
"0.6812307",
"0.6811412",
"0.6766053... | 0.6959373 | 12 |
Use the array's native sort method | def get_sorted_array
@ary.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def using_sort(array)\narray.sort\nend",
"def using_sort(array)\narray.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n sorted_array=array.sort\nend",
"def sort_array_asc(array)\n\t... | [
"0.83593535",
"0.83593535",
"0.8135982",
"0.8135982",
"0.8135982",
"0.8067925",
"0.8043106",
"0.7923096",
"0.7869841",
"0.7848484",
"0.7848484",
"0.7848484",
"0.7848484",
"0.7848484",
"0.7848484",
"0.7792767",
"0.7758906",
"0.7757075",
"0.76980895",
"0.76470274",
"0.76228076"... | 0.7109493 | 76 |
totals_arr = [] sum = 0 loop do break if arr.length == 0 totals_arr << sum = arr.shift + sum end totals_arr end | def running_total(arr)
totals_arr = []
acc = 0
arr.each do |num|
acc = acc + num
totals_arr << acc
end
totals_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_total arr\n totals = []\n sum = 0\n arr.each do |elm|\n sum += elm\n totals << sum\n end\n totals\nend",
"def sum(arr)\n return 0 if arr.empty?\n el = arr.shift\n total = sum(arr)\n total + el\nend",
"def sum_of_sums(arr)\n total_sum = 0\n dup_arr = arr.dup # make a copy to avoid m... | [
"0.8280244",
"0.8051251",
"0.7988912",
"0.79777217",
"0.79608136",
"0.7953595",
"0.7936917",
"0.79359597",
"0.7891125",
"0.78767204",
"0.7874809",
"0.78728706",
"0.78562427",
"0.7850454",
"0.7846423",
"0.7823093",
"0.78026164",
"0.7798185",
"0.7794741",
"0.77891934",
"0.77884... | 0.78732044 | 11 |
Invokes rake in the specified directory with the specified target | def invokeRake(directory, target)
cmd = "(cd #{directory}; rake #{target} BIN_DIR=../#{BIN_DIR} DEBUG_FLAG=#{DEBUG_FLAG})"
sh cmd
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invokeRake(directory, target)\n cmd = \"(cd #{directory}; rake #{target} LIB_DIR=../#{LIB_DIR} DEBUG_FLAG=#{DEBUG_FLAG})\"\n sh cmd\nend",
"def rake(*args) run_command('rake', args) end",
"def run_rake(task)\n run \"cd #{current_path} && rake #{task} RAILS_ENV=#{environment}\"\nend",
"def run_rake(tas... | [
"0.8038424",
"0.72597986",
"0.7108391",
"0.7108391",
"0.7108391",
"0.7050125",
"0.6764478",
"0.6604507",
"0.6604507",
"0.6595312",
"0.6496554",
"0.634112",
"0.62914366",
"0.62500584",
"0.6182974",
"0.61442274",
"0.6118453",
"0.609759",
"0.60698587",
"0.6042244",
"0.60379475",... | 0.8239398 | 0 |
Constructs a new task for the project/target combination. The target will invoke a rake target on the subproject | def createTask(project, target)
task "#{project}.#{target}" do
print "#######################################################\n"
invokeRake project, target
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_tasks\n super\n all_object_files = []\n all_object_folders = []\n @toolchains.each do |toolchain, sources|\n toolchain.add_include_paths(@api_headers+@configuration_headers)\n object_files, object_folders = toolchain.create_compile_tasks(sources)\n all_object_... | [
"0.6761918",
"0.67353636",
"0.66902137",
"0.64816827",
"0.646784",
"0.6325721",
"0.62509596",
"0.6201537",
"0.61972183",
"0.6140512",
"0.61384",
"0.6127104",
"0.61219263",
"0.6118963",
"0.61107564",
"0.6088339",
"0.6088339",
"0.6088339",
"0.6064164",
"0.60499454",
"0.6041911"... | 0.8077233 | 1 |
Action to list the alerts registered in the application. It also allows to search in the alerts by _name_ and/or _description_. [URL] GET /alerts [Parameters] page _(Optional)_ The page of results to show. q _(Optional)_ A search query to filter alerts. | def index
@alerts = Alert.all
# If an activation status is passed, get the specified alerts
check_active_param
@alerts = @alerts.where(:active => @active) if (@active != nil)
# If a search query is received, filter the results
if (!params[:q].blank?)
# Do the search
@query = params[:q]
@alerts = @alerts.where("$or" => [{:name => /#{@query}/i}, {:description => /#{@query}/i}])
end
# If a page number is received, save it (if not, the page is the first)
if (!params[:page].blank?)
page = params[:page].to_i
page = 1 if (page < 1)
else
page = 1
end
# Paginate!
@alerts = @alerts.page(page)
respond_to do |format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_alerts(opts = {})\n data, _status_code, _headers = list_alerts_with_http_info(opts)\n return data\n end",
"def list_alert(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[... | [
"0.734026",
"0.72697806",
"0.7262496",
"0.69386715",
"0.69386715",
"0.69386715",
"0.67378265",
"0.63825816",
"0.63825816",
"0.63803816",
"0.6277441",
"0.62561816",
"0.6194796",
"0.61825985",
"0.61007595",
"0.6085848",
"0.60785973",
"0.60614866",
"0.602489",
"0.6018239",
"0.60... | 0.7629379 | 0 |
Action to show the service creation form. [URL] GET /alerts/new | def new
@alert = Alert.new
respond_to do |format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n parameters = alert_params\n parameters[:service] = Service.where(:_id => parameters[:service_id]).first\n parameters[:hosts] = Host.where(:_id.in => parameters[:host_ids]).to_a if (!parameters[:host_ids].blank?)\n\n # Delete string'd id's\n parameters.delete(:service_id)\n parameters... | [
"0.7403234",
"0.6892984",
"0.68458104",
"0.6833722",
"0.6783962",
"0.6763968",
"0.6761493",
"0.66932",
"0.6658992",
"0.6657319",
"0.6631185",
"0.66295797",
"0.6619513",
"0.6585567",
"0.6565171",
"0.6549883",
"0.6518372",
"0.6511708",
"0.6500327",
"0.6500327",
"0.6500327",
"... | 0.6904004 | 1 |
Action to create a new alert with the data received from the form. [URL] POST /alerts [Parameters] alert All the data recolected of the new service. | def create
parameters = alert_params
parameters[:service] = Service.where(:_id => parameters[:service_id]).first
parameters[:hosts] = Host.where(:_id.in => parameters[:host_ids]).to_a if (!parameters[:host_ids].blank?)
# Delete string'd id's
parameters.delete(:service_id)
parameters.delete(:host_ids)
# Apply the params received
@alert = Alert.new(parameters)
respond_to do|format|
format.html{
# Can be saved?
if (@alert.save)
flash[:notice] = t("alerts.notice.created", :name => @alert.name)
redirect_to alert_path(@alert)
else
# If an error raises, show the form again.
render :action => :new
end
return
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @alert = Alert.new(alert_params)\n\n respond_to do |format|\n if @alert.save\n format.html { redirect_to root_path, notice: \"Has creado una nueva alerta. Pronto te avisaremos cuando encontremos lo que buscas\" }\n format.json { render :show, status: :created, location: @alert... | [
"0.80237335",
"0.7841779",
"0.77494395",
"0.75376034",
"0.74906987",
"0.7240869",
"0.71494323",
"0.71256834",
"0.711372",
"0.7078331",
"0.7041308",
"0.703248",
"0.67905915",
"0.6673066",
"0.6661133",
"0.6660909",
"0.6658149",
"0.664778",
"0.66343194",
"0.65970427",
"0.6585386... | 0.7783944 | 2 |
Action to show a the information about an existing alert. [URL] GET /alerts/:id [Parameters] id The identificator of the alert. | def show
load_alert
return if (@alert.blank?)
respond_to do|format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @alert = Alert.find(params[:id])\n end",
"def get_single_alert(alert_id)\n ret = http_get('/alert/' + alert_id)\n val = Alert.new(ret)\n val\n end",
"def show\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js... | [
"0.79979634",
"0.7519175",
"0.7086312",
"0.70855886",
"0.70855886",
"0.70668525",
"0.6982814",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.69535065",
"0.6932156",
"0.690927",
"0.67605275",
"0... | 0.5847941 | 61 |
Action to show a form to edit an existing alert. [URL] GET /alerts/:id/edit [Parameters] id The identificator of the alert. | def edit
load_alert
return if (@alert.blank?)
respond_to do|format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit(id)\n @post = flash[:form_data] || Post[id]\n\n # Make sure the post is valid\n if @post.nil?\n flash[:error] = 'The specified post is invalid'\n redirect_referrer\n end\n\n @title = \"Edit #{@post.title}\"\n\n render_view(:form)\n end",
"def edit(id)\n @user = flash[:for... | [
"0.72797257",
"0.6862649",
"0.6750023",
"0.658629",
"0.64910907",
"0.6414594",
"0.6365494",
"0.63514763",
"0.6281163",
"0.6280584",
"0.6280584",
"0.6260584",
"0.6255183",
"0.6244062",
"0.6214726",
"0.6209062",
"0.6200263",
"0.61911684",
"0.61878026",
"0.6187618",
"0.61816365"... | 0.6528518 | 4 |
Action to update an existing alert with the data received from the form. [URL] PUT /alerts/:id PATCH /alerts/:id [Parameters] id The identificator of the alert. alert The data recolected for the alert. | def update
load_alert
return if (@alert.blank?)
parameters = alert_params
parameters[:service] = Service.where(:_id => parameters[:service_id]).first if (!parameters[:service_id].blank?)
if (!parameters[:host_ids].blank?)
# Remove removed hosts
@alert.hosts.select{|h| parameters[:host_ids].include?(h.id.to_s) == false}.each{|h| @alert.hosts.delete(h)}
# Add the new hosts
host_ids_add = parameters[:host_ids].select{|h| @alert.host_ids.include?(h) == false}
Host.where(:_id.in => host_ids_add, :service_ids => parameters[:service_id]).to_a.each do |h|
@alert.hosts << h
end
else
# Empty the hosts array
parameters[:hosts] = []
end
respond_to do|format|
format.html{
# The alert can be updated?
if (@alert.update_attributes(parameters))
flash[:notice] = t("alerts.notice.updated", :name => @alert.name)
redirect_to alert_path(@alert)
else
# If an error raises, show the form again
render :action => :edit
end
return
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @alert = Alert.find(params[:id])\n\n respond_to do |format|\n if @alert.update_attributes(params[:alert])\n format.html { redirect_to @alert, notice: 'Alert was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.81832534",
"0.80246913",
"0.7664461",
"0.76615584",
"0.76027447",
"0.75688535",
"0.7137397",
"0.7094946",
"0.70573235",
"0.69820243",
"0.6944312",
"0.6930605",
"0.68623674",
"0.6847843",
"0.6759337",
"0.6756105",
"0.67323685",
"0.6707822",
"0.6655359",
"0.6655359",
"0.6655... | 0.6299407 | 35 |
Action to destroy an existing alert in the database. [URL] DELETE /alerts/:id [Parameters] id The identificator of the alert. | def destroy
load_alert
return if (@alert.blank?)
respond_to do|format|
format.html{
# The alert can be destroyed?
if (@alert.destroy)
flash[:notice] = t("alerts.notice.destroyed", :name => @alert.name)
redirect_to alerts_path()
else
flash[:error] = t("alerts.error.not_destroyed", :name => @alert.name)
redirect_to alert_path(@alert)
end
return
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @alert = Alert.find(params[:id])\n @alert.destroy\n\n respond_to do |format|\n format.html { redirect_to(alerts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @alert = Alert.find(params[:id])\n @alert.destroy\n\n respond_to do |format|\n format.h... | [
"0.7401773",
"0.7220935",
"0.7220762",
"0.7020628",
"0.6977127",
"0.6844175",
"0.6808137",
"0.67487633",
"0.6742521",
"0.6682758",
"0.66427904",
"0.66427904",
"0.6622791",
"0.6617259",
"0.6518994",
"0.6513909",
"0.645848",
"0.6434973",
"0.63731253",
"0.6353115",
"0.63018507",... | 0.6313611 | 20 |
Action to get a selector of hosts to monitor. [URL] GET /alerts/:id/service_hosts/:service_id GET /alerts/new/service_hosts/:service_id [Parameters] id The identificator of the alert. service_id The id of the service selected. | def get_service_hosts
if ((!params[:id].blank?) && (params[:id] != "new"))
load_alert
return if (@alert.blank?)
else
@alert = Alert.new()
end
@service = Service.where(:_id => params[:service_id]).first
respond_to do |format|
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n parameters = alert_params\n parameters[:service] = Service.where(:_id => parameters[:service_id]).first\n parameters[:hosts] = Host.where(:_id.in => parameters[:host_ids]).to_a if (!parameters[:host_ids].blank?)\n\n # Delete string'd id's\n parameters.delete(:service_id)\n parameters... | [
"0.6298764",
"0.6190481",
"0.586121",
"0.57544637",
"0.5661274",
"0.55310845",
"0.55279905",
"0.5453879",
"0.5428977",
"0.53472716",
"0.534589",
"0.53301156",
"0.5321866",
"0.5316694",
"0.52578276",
"0.51061404",
"0.50250846",
"0.5005147",
"0.49949074",
"0.4982914",
"0.497658... | 0.72990716 | 0 |
Action to index the users subscribed to an alert. [URL] GET /alerts/:id/users [Parameters] id The identificator of the alert. | def index_users
load_alert
return if (@alert.blank?)
# Preload the users
@users = User.where(:_id.in => @alert.user_ids)
respond_to do |format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end",
"def list_users_assigned_to_application(id, options = {})\n get(\"/apps/#{id}/users\", options)\n end",
"def index\n r = @api.get_users\n response = JSON.parse(r.body)\n if r.code == 200\n @users = respo... | [
"0.6632567",
"0.6505015",
"0.6478609",
"0.6368161",
"0.63468176",
"0.62839633",
"0.6229164",
"0.6226088",
"0.6219819",
"0.61918676",
"0.61918676",
"0.61918676",
"0.6167833",
"0.61538696",
"0.61467445",
"0.61335003",
"0.61173123",
"0.6112554",
"0.610501",
"0.60903084",
"0.6085... | 0.7120552 | 0 |
Action to subscribe a user to an alert. [URL] POST /alerts/:id/users/new [Parameters] id The identificator of the alert. user_id The identificator of the user. | def new_user
load_alert
return if (@alert.blank?)
@user = User.where(:_id => params[:user_id]).first
# Do the user exists?
if (@user.blank?)
flash[:error] = t("alerts.error.user_not_found")
redirect_to alert_users_path()
return
end
# is already subscribed?
if (@alert.user_ids.include?(@user.id))
flash[:notice] = t("alerts.notice.user_already_added", :name => @user.name, :alert => @alert.name)
redirect_to alert_users_path()
return
end
# Subscribe it
@alert.users << @user
respond_to do |format|
format.html{
if (@alert.save)
flash[:notice] = t("alerts.notice.user_added", :name => @user.name, :alert => @alert.name)
else
flash[:error] = t("alerts.error.user_not_added", :name => @user.name, :alert => @alert.name)
end
redirect_to alert_users_path()
return
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe! (user_id)\n check_auth :subscribe\n \n response = connection.post do |req|\n req.url \"/user/subscribe/#{user_id}\"\n req.body = { :format => @format }\n end\n response\n end",
"def create\n @user = User.new(params[:name])\n\n respond_to do |format|\n... | [
"0.66719395",
"0.6199178",
"0.6140618",
"0.6124611",
"0.6028716",
"0.59936076",
"0.5986068",
"0.5929735",
"0.5923294",
"0.5898534",
"0.5898151",
"0.587678",
"0.5876318",
"0.58615786",
"0.5856243",
"0.5836502",
"0.58362",
"0.5819785",
"0.58182454",
"0.5796434",
"0.5792951",
... | 0.76909804 | 0 |
Action to desubscribe a user to an alert. [URL] DELETE /alerts/:id/users/:user_id [Parameters] id The identificator of the alert. user_id The identificator of the user. | def delete_user
load_alert
return if (@alert.blank?)
@user = User.where(:_id => params[:user_id]).first
# Does the user exist?
if (@user.blank?)
flash[:error] = t("alerts.error.user_not_found")
redirect_to alert_users_path()
return
end
# Disassociate the user from the alert
@alert.users.delete(@user)
respond_to do |format|
format.html{
if (@alert.save)
flash[:notice] = t("alerts.notice.user_deleted", :name => @user.name, :alert => @alert.name)
else
flash[:error] = t("alerts.error.user_not_deleted", :name => @user.name, :alert => @alert.name)
end
redirect_to alert_users_path()
return
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe! (user_id)\n check_auth :unsubscribe\n \n response = connection.post do |req|\n req.url \"/user/unsubscribe/#{user_id}\"\n req.body = { :format => @format }\n end\n response\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n U... | [
"0.7552905",
"0.70392185",
"0.7001693",
"0.6896013",
"0.6823183",
"0.6727134",
"0.6705892",
"0.67053705",
"0.6678748",
"0.6648549",
"0.6636253",
"0.6633762",
"0.6619307",
"0.65837765",
"0.6578347",
"0.65695596",
"0.6569365",
"0.65563995",
"0.65563995",
"0.6555059",
"0.6543067... | 0.69371045 | 3 |
Action to index the alert records of an alert. [URL] GET /alerts/records/:id [Parameters] id The identificator of the alert. | def index_records
# If there is an ID passed, try to load the alert
if (!params[:id].blank?) && (params[:id] != "all")
load_alert
return if (@alert.blank?)
end
# if there is an alert loaded, filter the results
if (!@alert.blank?)
@alert_records = AlertRecord.where(:alert_id => @alert.id)
else
@alert_records = AlertRecord.all
end
# Ordering results
@alert_records = @alert_records.desc(:open).desc(:updated_at)
# If a page number is received, save it (if not, the page is the first)
if (!params[:page].blank?)
page = params[:page].to_i
page = 1 if (page < 1)
else
page = 1
end
# Paginate!
@alert_records = @alert_records.page(page)
respond_to do |format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @records = Record.all\n end",
"def index\n @records = Record.all\n end",
"def index\n @records = Record.all\n end",
"def index\n @records = Record.all\n end",
"def index\n @records = Record.all\n end",
"def index\n @records = record_class.all\n end",
"def show\n r... | [
"0.6688546",
"0.6688546",
"0.6688546",
"0.6688546",
"0.6688546",
"0.6526417",
"0.6182347",
"0.6173468",
"0.6105308",
"0.6105308",
"0.6105308",
"0.604903",
"0.59701204",
"0.59701204",
"0.59078777",
"0.5891616",
"0.58842576",
"0.5834743",
"0.5792145",
"0.5773748",
"0.5769474",
... | 0.74467623 | 0 |
Action to show a the information about an existing alert record. [URL] GET /alerts/record/:id [Parameters] id The identificator of the alert record. | def show_record
load_alert_record
return if (@alert_record.blank?)
respond_to do|format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @alert = Alert.find(params[:id])\n end",
"def load_alert_record(redirect = true)\n if (params[:id].blank?)\n @alert_record = nil\n return @alert_record\n end\n\n @alert_record = AlertRecord.where(:_id => params[:id]).first\n\n if (@alert_record.blank? && redirect)\n # If... | [
"0.69684535",
"0.6802821",
"0.664518",
"0.664518",
"0.64987755",
"0.64867157",
"0.6376431",
"0.63601536",
"0.63330734",
"0.6276694",
"0.6204151",
"0.6193815",
"0.6184122",
"0.61518466",
"0.6122632",
"0.6107283",
"0.60924226",
"0.60923046",
"0.60923046",
"0.60543096",
"0.60519... | 0.6636534 | 4 |
Function to check the existence of the active parameter in the URL. Also checks if the activation status is valid. | def check_active_param
if (!params[:active].blank?)
if (params[:active] == true || params[:active] == "true")
@active = true
elsif (params[:active] == false || params[:active] == "false")
@active = false
end
end
return @active
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_active?\n begin\n response = Net::HTTP.get_response URI.parse(self.url)\n active_status = %w(200 301 302)\n active_status.include? response.code\n rescue\n false\n end \n end",
"def active?\n activation_code.nil?\n end",
"def active?\n activation_code.nil?\... | [
"0.7326444",
"0.6742991",
"0.6742991",
"0.6742991",
"0.6733753",
"0.6563503",
"0.65603346",
"0.6546986",
"0.6473968",
"0.6429444",
"0.6364737",
"0.6364737",
"0.6364737",
"0.6364737",
"0.6364737",
"0.6364737",
"0.6364737",
"0.6364737",
"0.6364737",
"0.63614964",
"0.6357283",
... | 0.71533406 | 1 |
Function lo load an alert from the database using id parameter in the URL. | def load_alert(redirect = true)
if (params[:id].blank?)
@alert = nil
return @alert
end
@alert = Alert.where(:_id => params[:id]).first
if (@alert.blank? && redirect)
# If not found, show an error and redirect
flash[:error] = t("alerts.error.not_found")
redirect_to alerts_path()
end
return @alert
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_alert\n@alert = Alert.find(params[:id])\nend",
"def show\n @alert = Alert.find(params[:id])\n end",
"def set_alert\n @alert = Alert.find(params[:id])\n end",
"def set_alert\n @alert = Alert.find(params[:id])\n end",
"def set_alert\n @alert = Alert.find(params[:id])\n end... | [
"0.7227944",
"0.7226281",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.7105152",
"0.709702",
"0.69173455",
"0.6835383",
"0.680298",
"0.6508832",
"0.63834715",
"0.6239125",
"0.6238793",
"0.6238793",
"... | 0.7132379 | 2 |
Function lo load an alert from the database using id parameter in the URL. | def load_alert_record(redirect = true)
if (params[:id].blank?)
@alert_record = nil
return @alert_record
end
@alert_record = AlertRecord.where(:_id => params[:id]).first
if (@alert_record.blank? && redirect)
# If not found, show an error and redirect
flash[:error] = t("alerts.error.record_not_found")
redirect_to alert_records_path()
end
return @alert_record
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_alert\n@alert = Alert.find(params[:id])\nend",
"def show\n @alert = Alert.find(params[:id])\n end",
"def load_alert(redirect = true)\n if (params[:id].blank?)\n @alert = nil\n return @alert\n end\n\n @alert = Alert.where(:_id => params[:id]).first\n\n if (@alert.blank? && redi... | [
"0.7229217",
"0.72268593",
"0.7131562",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7107516",
"0.7099633",
"0.69197506",
"0.68382335",
"0.68033385",
"0.6385434",
"0.62401956",
"0.6239859",
"0.6239859"... | 0.6506354 | 17 |
Function to check if there is any existing service before executing the create/update actions that require at least a service. | def check_service_existence
if (Service.all.count == 0)
flash[:error] = t("alerts.error.services_not_exist")
redirect_to :back
end
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist?(service)\n !service_list[service].nil?\n end",
"def dt_service_exist?\n pattern = /#{DT_SERVICE_NAME}/\n candidates = @services.select do |candidate|\n (\n (candidate['label'] == 'user-provided' && candidate['name'] =~ pattern) ||\n candidate['label'] =~ patt... | [
"0.7057028",
"0.6763985",
"0.6672849",
"0.6668222",
"0.655131",
"0.6508932",
"0.6483152",
"0.6483152",
"0.6400949",
"0.638322",
"0.638322",
"0.6380864",
"0.6376785",
"0.6376785",
"0.6376785",
"0.6376785",
"0.6279583",
"0.6257389",
"0.6219823",
"0.6202116",
"0.61907536",
"0.... | 0.72131056 | 0 |
Strong parameters method to prevent from massive assignment in the _Alert_ model. [Returns] The filtered version of params[:alert]. | def alert_params
params.require(:alert).permit(:name, :description, :active, :service_id, :condition, :limit, :condition_target, :error_control, :host_ids => [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alert_params\n params.require(:alert).permit(\n :search_id, :active, :description, :last_run, :last_status_change, :name, :status,\n :threshold_count, :threshold_operator, :threshold_time_seconds, :logs_in_email,\n :history\n )\n end",
"def alert_params\n params.require(:alert).p... | [
"0.7241244",
"0.7027012",
"0.7007138",
"0.6972872",
"0.6972617",
"0.66816443",
"0.66768223",
"0.6660256",
"0.66550475",
"0.6582182",
"0.6510155",
"0.6508593",
"0.64569014",
"0.64548236",
"0.6332735",
"0.62669295",
"0.62542444",
"0.6226492",
"0.620233",
"0.5973892",
"0.5939278... | 0.7070925 | 1 |
every consonant character is doubled. Vowels (a,e,i,o,u), digits, punctuation, and whitespace should not be doubled. | def double_consonants(str)
result = ""
str.chars.each do |ch|
result << if ch.downcase.match?(/[a-z&&[^aeiou]]/)
ch * 2
else
ch
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_consonants(str)\n str.chars.each_with_object('') do |c, double_str|\n if c =~ /[^(aeiouAEIOU)|\\W|\\d]/\n double_str << c * 2\n else\n double_str << c\n end\n end\nend",
"def double_consonants(str)\n str.chars.each_with_object('') do |char, new_str|\n if char =~ /[^aeiou]/ && ... | [
"0.78938305",
"0.77814555",
"0.7697116",
"0.7647818",
"0.7641288",
"0.76198786",
"0.74884564",
"0.748378",
"0.7477863",
"0.7475337",
"0.74550897",
"0.7429336",
"0.7425032",
"0.74052304",
"0.73873353",
"0.73710424",
"0.7307461",
"0.72561395",
"0.7253952",
"0.724991",
"0.723262... | 0.76830995 | 3 |
GET /customers GET /customers.json | def index
@customers = Customer.where(:warehouse_id=>current_user.parent_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @customers = @user.customers.all\n render json: @customers\n end",
"def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end",
"def index\n @user = current_user\n @customers = @user.custo... | [
"0.80477434",
"0.7958279",
"0.78736347",
"0.7785999",
"0.7759871",
"0.7743631",
"0.7737657",
"0.7650475",
"0.7650475",
"0.7644552",
"0.76392215",
"0.7563173",
"0.7439835",
"0.74304175",
"0.74225414",
"0.7395726",
"0.72824943",
"0.72764957",
"0.7261613",
"0.72505057",
"0.72505... | 0.0 | -1 |
GET /customers/1 GET /customers/1.json | def show
@user=User.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_customer(id)\n get(\"customers/#{id}\")\n end",
"def get_customer(id)\n get(\"customers/#{id}\")\n end",
"def index\n @customers = @user.customers.all\n render json: @customers\n end",
"def index\n @user = current_user\n @customers = @user.custom... | [
"0.78559196",
"0.78559196",
"0.7680941",
"0.7600807",
"0.75337946",
"0.75153816",
"0.7500419",
"0.7383616",
"0.73375285",
"0.73375285",
"0.73375285",
"0.73375285",
"0.73375285",
"0.73375285",
"0.7316646",
"0.7307954",
"0.728091",
"0.7196688",
"0.7188413",
"0.71713734",
"0.716... | 0.0 | -1 |
POST /customers POST /customers.json | def create
@customer = Customer.new(customer_params.map{|k,v| {k.to_sym => v.class == ActionController::Parameters ? [v.to_hash] : v.to_s}}.reduce({}, :merge))
respond_to do |format|
if @customer.save
format.html { redirect_to @customer, notice: 'Customer was successfully created.' }
format.json { render :show, status: :created, location: @customer }
else
format.html { render :new }
format.json { render json: @customer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @customer = @user.customers.build(customer_params)\n if @customer.save\n render json: @customer, status: :created\n else\n render json: @customer.errors, status: :unprocessable_entity\n end\n\n ... | [
"0.7583831",
"0.7370059",
"0.7276722",
"0.7225282",
"0.7225083",
"0.71425253",
"0.7117077",
"0.7109782",
"0.70759284",
"0.7067933",
"0.70547545",
"0.7036328",
"0.7036328",
"0.7035178",
"0.7033539",
"0.7017762",
"0.70175195",
"0.70175195",
"0.70175195",
"0.70175195",
"0.701751... | 0.71037143 | 8 |
PATCH/PUT /customers/1 PATCH/PUT /customers/1.json | def update
respond_to do |format|
if @customer.update(customer_params.keep_if{|p,q| q.class != ActionController::Parameters})
@customer.address.update(customer_params[:address_attributes])
@customer.contact.update(customer_params[:contact_attributes])
format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @customer }
else
format.html { render :edit }
format.json { render json: @customer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end",
"def update\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n #format.html { redirect_to customers_path }\n format.json { head :ok ... | [
"0.6988014",
"0.6921667",
"0.6921389",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.6746401",
"0.67379916",
"0.6729548",
"0.669213",
"0.669213",
"0.669213",
"0.6614732",
"0.66107404",
"0.6601309",
"0.6599307",
"0.6581087",
"0.65642476",
"... | 0.6457318 | 46 |
DELETE /customers/1 DELETE /customers/1.json | def destroy
@customer.destroy
respond_to do |format|
format.html { redirect_to customers_url, notice: 'Customer was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |for... | [
"0.7459522",
"0.7459522",
"0.74481064",
"0.74481064",
"0.74481064",
"0.74481064",
"0.74481064",
"0.74481064",
"0.74481064",
"0.74353355",
"0.7429028",
"0.7429028",
"0.7429028",
"0.7429028",
"0.7429028",
"0.7429028",
"0.7429028",
"0.7429028",
"0.73638636",
"0.7328162",
"0.7298... | 0.7140883 | 43 |
Use callbacks to share common setup or constraints between actions. | def set_customer
@customer = Customer.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def customer_params
params.require(:customer).permit(:customer_name, :customer_code, :warehouse_id, :warehouse_code, :office_id, contact_attributes:[:landline,:extension,:mobilenumber1,:mobilenumber2,:email],address_attributes:[:address1,:address2,:city,:state,:country])
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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
Setup an authenticated connection to the OM Api | def initialize(opts = {})
@endpoint = opts[:endpoint] || 'https://app.organisedminds.com/'
@client_id = opts[:client_id] || raise("We need a client-id")
@client_secret = opts[:client_secret] || raise("We need a client-secret")
@scopes = opts[:scopes] || [ :read ]
@agent = Faraday.new(:url => @endpoint) do |faraday|
faraday.use :cookie_jar
faraday.request :url_encoded
faraday.adapter *opts[:adapter] || Faraday.default_adapter
faraday.headers['content-type'] = 'application/json'
if opts[:debug] == true
faraday.response :logger
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection\n @connection ||= if authenticated?\n RestClient::Resource.new(api_uri.to_s, @username, @password)\n else\n RestClient::Resource.new(api_uri.to_s)\n end\n end",
"def temp_auth\n response = get \"auth... | [
"0.6731496",
"0.67018193",
"0.66278327",
"0.65887547",
"0.65502834",
"0.6353731",
"0.6318312",
"0.630529",
"0.62919354",
"0.628642",
"0.6220967",
"0.6209995",
"0.6208145",
"0.6162073",
"0.61418146",
"0.61409074",
"0.613969",
"0.612585",
"0.61213094",
"0.6118448",
"0.6112211",... | 0.0 | -1 |
Perform a GET request | def get(path, data={})
request(:get, path, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end",
"def get\n start { |connection| connection.request http :Get }\n end",
"def do_get\n ... | [
"0.8152758",
"0.806111",
"0.80539304",
"0.79784244",
"0.79784244",
"0.7838251",
"0.78354996",
"0.78354996",
"0.77927583",
"0.77892256",
"0.77778345",
"0.77611405",
"0.7745449",
"0.77164996",
"0.7672968",
"0.7661916",
"0.7595133",
"0.75779617",
"0.7576617",
"0.756813",
"0.7555... | 0.73742414 | 58 |
Perform a POST request | def post(path, data={})
request(:post, path, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def post\n resource.post(request, response)\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def post(url, post_vars={})\n sen... | [
"0.79024845",
"0.7838824",
"0.7816926",
"0.77099574",
"0.77091825",
"0.7653466",
"0.7597337",
"0.7544226",
"0.74662435",
"0.74489796",
"0.7427801",
"0.74234486",
"0.74013907",
"0.7383522",
"0.7363137",
"0.73415595",
"0.73223567",
"0.7313033",
"0.73035455",
"0.7267529",
"0.726... | 0.7108902 | 45 |
Perform a PUT request | def put(path, data={})
request(:put, path, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(*args)\n request :put, *args\n end",
"def put!\n request! :put\n end",
"def put(*args)\n request(:put, *args)\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def perform_put(path, options = {})\n perform_reques... | [
"0.82389766",
"0.81615865",
"0.8139411",
"0.80490917",
"0.8022917",
"0.79202795",
"0.78235656",
"0.7817625",
"0.779413",
"0.77594733",
"0.77217585",
"0.7713028",
"0.77125263",
"0.76946163",
"0.76946163",
"0.76928",
"0.76903844",
"0.76903844",
"0.76903844",
"0.7686401",
"0.768... | 0.76078635 | 41 |
Perform a DELETE request | def delete(path, data={})
request(:delete, path, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n request(:delete)\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"del... | [
"0.8536471",
"0.8378405",
"0.83550817",
"0.83550817",
"0.8323079",
"0.82867426",
"0.82867426",
"0.82253987",
"0.81852996",
"0.8145603",
"0.8133176",
"0.81054914",
"0.81054914",
"0.81054914",
"0.81054914",
"0.8067572",
"0.7978741",
"0.790326",
"0.7859588",
"0.7848933",
"0.7820... | 0.75565785 | 60 |
Perform a HEAD request | def head(path, data={})
request(:head, path, data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def head(path)\n request 'HEAD', path\n end",
"def http_head(uri)\n http(uri, :http_method => 'head')\n end",
"def http_head\n return @head if defined?(@head)\n begin\n @head = conn.request(http_request(:head, resource[:source]))\n fail \"#{resource[:http_verb].to_s.upcase} #{resour... | [
"0.8272921",
"0.8121206",
"0.79404664",
"0.78960806",
"0.7895889",
"0.7895889",
"0.78953785",
"0.7877307",
"0.7673712",
"0.7603142",
"0.7537705",
"0.7534993",
"0.7470162",
"0.7465292",
"0.7444265",
"0.740834",
"0.7407242",
"0.73743105",
"0.7357283",
"0.7354718",
"0.73525304",... | 0.7465599 | 13 |
auto complete search for quest | def quest_autocomplete
render json: Quest.search(params[:query], where: { :group_id => @user.wrapper_group.id})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findorsuggest()\n \n end",
"def autocomplete; end",
"def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end",
"def auto_co... | [
"0.75734234",
"0.71830136",
"0.6902254",
"0.67994446",
"0.6773764",
"0.67401993",
"0.6713767",
"0.6676064",
"0.662794",
"0.66222584",
"0.654764",
"0.65425867",
"0.65410644",
"0.65326715",
"0.6524823",
"0.6483522",
"0.6437802",
"0.64359456",
"0.6431746",
"0.64205676",
"0.64148... | 0.71819603 | 2 |
auto complete search for record, quest and campaign | def all_autocomplete
quests = Quest.search(params[:query], where: { :group_id => @user.wrapper_group.id})
recs = Record.search(params[:query], where: { :group_id => @user.wrapper_group.id})
render json: Search.json(quests.results + recs.results)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end",
"def autocomplete\r\n# return '' unless session[:edit_mode] > 0 # \r\n retu... | [
"0.72117686",
"0.6935926",
"0.68776965",
"0.68259245",
"0.6804525",
"0.67708963",
"0.6766838",
"0.67333305",
"0.6709296",
"0.6705312",
"0.66823095",
"0.6648196",
"0.66409165",
"0.6623571",
"0.6620798",
"0.6590435",
"0.65527",
"0.64900714",
"0.64672875",
"0.64652604",
"0.64617... | 0.7028649 | 1 |
GET /commit_filepaths GET /commit_filepaths.json | def index
@commit_filepaths = CommitFilepath.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_files_in_commit(commit)\n\tfiles = {}\n\tcommit.diffs.each do | diff |\n\t\tfiles[diff.a_path] = nil unless files.has_key? diff.a_path\n\t\tfiles[diff.b_path] = nil unless files.has_key? diff.b_path\n\t\t# what about diff.deleted_file and diff.new_file?\n\tend\n\treturn files.keys\nend",
"def files_at_co... | [
"0.6951814",
"0.67700416",
"0.6696471",
"0.6359521",
"0.6351097",
"0.6117724",
"0.6080518",
"0.60698694",
"0.6019396",
"0.60059994",
"0.5992208",
"0.5892106",
"0.58767265",
"0.58048034",
"0.5798398",
"0.5767319",
"0.5717499",
"0.56756264",
"0.5629655",
"0.56192356",
"0.561748... | 0.7456648 | 0 |
GET /commit_filepaths/1 GET /commit_filepaths/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @commit_filepaths = CommitFilepath.all\n end",
"def get_files_in_commit(commit)\n\tfiles = {}\n\tcommit.diffs.each do | diff |\n\t\tfiles[diff.a_path] = nil unless files.has_key? diff.a_path\n\t\tfiles[diff.b_path] = nil unless files.has_key? diff.b_path\n\t\t# what about diff.deleted_file and di... | [
"0.73885286",
"0.6709463",
"0.6677118",
"0.6676969",
"0.6498145",
"0.63304156",
"0.61476487",
"0.61163414",
"0.6060172",
"0.60272276",
"0.5995217",
"0.58763325",
"0.58488333",
"0.58412236",
"0.5705098",
"0.56625724",
"0.5635051",
"0.5591503",
"0.5586235",
"0.5580552",
"0.5526... | 0.0 | -1 |
POST /commit_filepaths POST /commit_filepaths.json | def create
@commit_filepath = CommitFilepath.new(commit_filepath_params)
respond_to do |format|
if @commit_filepath.save
format.html { redirect_to @commit_filepath, notice: 'Commit filepath was successfully created.' }
format.json { render :show, status: :created, location: @commit_filepath }
else
format.html { render :new }
format.json { render json: @commit_filepath.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_commit_filepath(filepaths, commit_hash)\n filepaths.each do |str_path, churn|\n @con.exec_prepared('fileInsert', [commit_hash,str_path, churn])\n end\n end",
"def commit_filepath_params\n params.fetch(:commit_filepath, {})\n end",
"def index\n @commit_filepaths = CommitFilepat... | [
"0.6715083",
"0.6302119",
"0.61116266",
"0.5731861",
"0.57165325",
"0.5666504",
"0.56485254",
"0.5558725",
"0.55565107",
"0.54922825",
"0.5467764",
"0.5414808",
"0.54037255",
"0.53529286",
"0.53513163",
"0.5346149",
"0.53448796",
"0.53245085",
"0.5288588",
"0.5283454",
"0.526... | 0.6221837 | 2 |
PATCH/PUT /commit_filepaths/1 PATCH/PUT /commit_filepaths/1.json | def update
respond_to do |format|
if @commit_filepath.update(commit_filepath_params)
format.html { redirect_to @commit_filepath, notice: 'Commit filepath was successfully updated.' }
format.json { render :show, status: :ok, location: @commit_filepath }
else
format.html { render :edit }
format.json { render json: @commit_filepath.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(path, **args); end",
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end... | [
"0.6103378",
"0.5856162",
"0.58377904",
"0.5801592",
"0.5675454",
"0.56435007",
"0.56307733",
"0.56124526",
"0.5610535",
"0.5572411",
"0.55660915",
"0.5548735",
"0.5491657",
"0.5464166",
"0.5457339",
"0.54044825",
"0.54044825",
"0.54044825",
"0.54044825",
"0.54018867",
"0.540... | 0.66460806 | 0 |
DELETE /commit_filepaths/1 DELETE /commit_filepaths/1.json | def destroy
@commit_filepath.destroy
respond_to do |format|
format.html { redirect_to commit_filepaths_url, notice: 'Commit filepath was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def b2_delete_file(file)\n\n if parse_files_json(file) == {}\n\n puts \"File not present\"\n\n else\n \n result_hash = convert_json(b2_delete_file_version(file))\n\n if result_hash[\"fileName\"] == file\n puts \"File deleted successfully\"\n else\n puts \"Error deleting... | [
"0.6758197",
"0.66282016",
"0.66155815",
"0.6552906",
"0.64551204",
"0.63730943",
"0.6341973",
"0.6308579",
"0.62984496",
"0.62692857",
"0.6255808",
"0.6246104",
"0.6217623",
"0.6192738",
"0.618808",
"0.6129804",
"0.6125374",
"0.6125374",
"0.61101764",
"0.6100545",
"0.6093411... | 0.7451704 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_commit_filepath
@commit_filepath = CommitFilepath.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def commit_filepath_params
params.fetch(:commit_filepath, {})
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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
Public methods for ac_as_api | def followers_count
self.followers.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api; end",
"def api; end",
"def apis; end",
"def api_only; end",
"def api_only; end",
"def api_only; end",
"def api\n @api\n end",
"def api_mode; end",
"def set_api(*args); end",
"def set_api(*args); end",
"def parent_api; end",
"def parent_api; end",
"def api_only=(_arg0); end",
... | [
"0.7366039",
"0.7366039",
"0.7157097",
"0.69463927",
"0.69463927",
"0.69463927",
"0.6802661",
"0.6786365",
"0.6748311",
"0.6748311",
"0.6721838",
"0.6721838",
"0.66876954",
"0.66224986",
"0.65395206",
"0.6448451",
"0.6443889",
"0.6384711",
"0.6375172",
"0.62735736",
"0.627357... | 0.0 | -1 |
Write a function that given an array, now CHANGES each of the numbers to be twice as big. This should mutate the original array! | def array_times_two!(arr) #note the ! to indicate what it does
arr.each_with_index { |num, idx| arr[idx] = num*2 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_numbers(array)\n new_array = []\n\n array.each do |number|\n new_array << number *= 2\n end\n return new_array\nend",
"def double_numbers(array)\n\tarray.map { |integer| integer * 2 }\t\nend",
"def double_even_numbers(array)\n doubled_array = array.clone\n\n (array.length - 1).step(... | [
"0.7143005",
"0.6805797",
"0.6798778",
"0.6788144",
"0.6746983",
"0.6699699",
"0.6634698",
"0.6632288",
"0.6610793",
"0.658726",
"0.6578772",
"0.6568035",
"0.6559131",
"0.6540778",
"0.65353334",
"0.6531856",
"0.6516556",
"0.65008646",
"0.6496055",
"0.6492201",
"0.64829344",
... | 0.68613404 | 1 |
Write a function that given an array, returns another array of only the unique elements. I.e., return a version without duplicates. | def uniq(arr)
new_array = []
arr = arr.sort
arr.each_with_index do |num, idx|
new_array << num if num != arr[idx + 1]
end
new_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_uniq(array)\n result = []\n array.each { |ele| result << ele unless result.include?(ele) }\n result\nend",
"def using_uniq(array)\n array.uniq\n end",
"def uniq(array)\n finalArray = []\n array.each do |element|\n if !finalArray.include?(element)\n finalArray.push... | [
"0.85015875",
"0.8421703",
"0.83882827",
"0.8382231",
"0.8357935",
"0.83399683",
"0.8296084",
"0.8285239",
"0.8283458",
"0.8264928",
"0.8264928",
"0.8233076",
"0.8223728",
"0.8223728",
"0.8223728",
"0.8223728",
"0.8223728",
"0.8223728",
"0.82081527",
"0.8174246",
"0.817381",
... | 0.76433396 | 44 |
A Slippery Number is a number is that has 3 as a factor or has 5 as a factor, but does not have both as factors. For example, 6 is a Slippery Number, but 30 is not. Write a function that given an N, returns an array of the first N Slippery numbers. You'll want to write a helper function that helps you determine which numbers are Slippery. | def slippery_numbers(n)
num = 1
result = []
while result.length < n
result << num if is_slippery?(num)
num += 1
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slippery_numbers(n)\n slippery_nums = []\n curr_num = 0\n while slippery_nums.length < n\n slippery_nums << curr_num if is_slippery?(curr_num)\n curr_num += 1\n end\n slippery_nums\n end",
"def slippery_numbers(n)\n array = []\n counter = 0\n numbers = 0\n while (counter... | [
"0.83439183",
"0.82858",
"0.81821746",
"0.81821746",
"0.7393893",
"0.59299415",
"0.5917558",
"0.58745056",
"0.5851067",
"0.5777433",
"0.5772545",
"0.57675886",
"0.5761323",
"0.5750955",
"0.5748554",
"0.57400185",
"0.57368875",
"0.57148546",
"0.57079905",
"0.5698356",
"0.56491... | 0.82373935 | 2 |
Write a function that finds whether any two elements in the array sum to 0. If it does, return true; else, return false. | def two_sum_to_zero?(arr)
arr.each_with_index do |n1, idx1|
arr.each_with_index do |n2, idx2|
next if idx1 == idx2
return true if (n1 + n2).zero?
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_sum_to_zero?(array)\n array.each_with_index do |element, index|\n array.each_with_index do |element2, index2|\n if element + element2 == 0 and index != index2\n return true\n end\n end\n end\n return false\nend",
"def zero_sum?(array)\n (0...ar... | [
"0.8394237",
"0.83940583",
"0.830928",
"0.827356",
"0.81459486",
"0.8121386",
"0.81028754",
"0.7764583",
"0.77233285",
"0.76961035",
"0.7662283",
"0.7648399",
"0.7640471",
"0.7600156",
"0.7395936",
"0.73931307",
"0.7374467",
"0.7362017",
"0.73169756",
"0.7314895",
"0.7314512"... | 0.82066303 | 4 |
A magic number is a number whose digits, when added together, sum to 7. For example, the number 34 would be a magic number, because 3 + 4 = 7. Write a function that finds the first N many magic numbers. You'll want to write a helper function that checks whether a given number is a magic number. Reminder: you can convert an integer to a string using to_s. You can convert a string back to an integer using to_i. | def magic_numbers(count)
num = 1
result = []
while result.length < count
result << num if is_magic_number?(num)
num += 1
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magic_number?(n)\r\n \r\nend",
"def magic_number?(n)\n n.to_s.split('').each.map {|ch| ch.to_i}.reduce(:+) == 7 \nend",
"def find_primes_magic_value(magic_number)\n @primes = []\n number = 2\n while magic_number > 1\n if magic_number % number == 0\n magic_number /= number\n @p... | [
"0.72970706",
"0.7033409",
"0.64717877",
"0.63664323",
"0.630829",
"0.621672",
"0.61688673",
"0.6160541",
"0.61272424",
"0.60939336",
"0.6055924",
"0.6055093",
"0.60417634",
"0.6034535",
"0.60342854",
"0.59959614",
"0.59762275",
"0.59742683",
"0.59689856",
"0.59504205",
"0.58... | 0.6747305 | 2 |
describe "initial_round" do it "calls on deal_card twice and returns the sum" do expect(self).to receive(:deal_card).at_least(:twice).and_return(6) expect(initial_round).to eq(12) end it "calls on the 'display_card_total' to print sum of cards" do expect(self).to receive(:deal_card).at_least(:twice).and_return(6) expect($stdout).to receive(:puts).with(/Your cards add up to /) initial_round end end | def hit?(card_total)
# code hit? here
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_round\n display_card_total(deal_card + deal_card)\n # binding.pry\nend",
"def initial_round\n card_total = deal_card + deal_card\n display_card_total(card_total)\n card_total\nend",
"def initial_round\n total = deal_card + deal_card\n display_card_total(total)\n return total\nend",
"def i... | [
"0.6851482",
"0.6777375",
"0.67634237",
"0.6745637",
"0.6612278",
"0.63837755",
"0.6380489",
"0.63374615",
"0.6334782",
"0.6315005",
"0.6227981",
"0.62184477",
"0.61767113",
"0.61735654",
"0.6167525",
"0.6162733",
"0.6161246",
"0.61575246",
"0.61502117",
"0.6150105",
"0.61466... | 0.0 | -1 |
Turn a large number into 3digit chunks | def chunkify(number)
chunks = []
while number > 0
number, chunk = number.divmod(1000)
chunks << chunk
end
chunks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by_hundreds(num)\n str = num.to_i.to_s\n a = []\n str.split(//).reverse.each_slice(3) { |slice| a << slice }\n\n t = str.length % 3\n t = 3-t if t>0\n for i in 1..t\n a << 0\n end\n\n new_a = []\n a.each do |item|\n new_a << item\n end\n\n new_a.flatten.join\nend",
"def split_in_three... | [
"0.7021607",
"0.6968924",
"0.68689406",
"0.65382355",
"0.63851935",
"0.6312001",
"0.6259925",
"0.62322783",
"0.6174289",
"0.615428",
"0.61369145",
"0.611924",
"0.6113153",
"0.61028755",
"0.60940164",
"0.60508156",
"0.60093504",
"0.60053647",
"0.598869",
"0.5980942",
"0.597609... | 0.69161856 | 2 |
turn a number into text 0999 | def textify(number)
return UNITS[number] if number < UNITS.length
tens, units = number.divmod(10)
hundreds, tens = tens.divmod(10)
out = ''
out << "#{UNITS[hundreds]} hundred " if hundreds > 0
out << "#{TENS[tens]}" if tens > 0 && number >= 20
out << "-" if tens > 0 && units > 0
out << "#{UNITS[units]}" if units > 0
out.strip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_to_s\n case\n when number < 10 then return \"00#{number}\"\n when number < 100 then return \"0#{number}\"\n else return \"#{number}\"\n end\n end",
"def number_to_string_with_zero(number, characters_count = 2 )\n num_str = number.to_s\n\n if num_str.length < characters_coun... | [
"0.7762979",
"0.74668497",
"0.73332614",
"0.73171526",
"0.7223777",
"0.7205349",
"0.72049826",
"0.7194729",
"0.71696794",
"0.71445733",
"0.7122663",
"0.71006596",
"0.7069555",
"0.7069555",
"0.7022905",
"0.7000965",
"0.699324",
"0.6983694",
"0.6974595",
"0.69627327",
"0.695457... | 0.74288946 | 2 |
Returns the Arraypack code that matches this type The endianness is the one of the local OS | def compute_pack_code(size: self.size, integer: self.integer?, unsigned: self.unsigned?)
if integer
INTEGER_PACK_CODES[[size, unsigned, ModelKit::Types.big_endian?]]
else
FLOAT_PACK_CODES[[size, ModelKit::Types.big_endian?]]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def native_endian\n if \"\\0\\1\".unpack(\"s\").first == 1\n :big\n elsif \"\\0\\1\".unpack(\"s\").first == 256\n :little\n else\n raise(\"Cannot determine endianness\")\n end\n end",
"def protocol_type\n self[:p_type].to_endian(:big)\n ... | [
"0.6694701",
"0.6540983",
"0.6429136",
"0.6191091",
"0.61608356",
"0.6076408",
"0.60125005",
"0.5882033",
"0.58245844",
"0.58080626",
"0.57985103",
"0.57800794",
"0.57346034",
"0.570882",
"0.5704685",
"0.5697191",
"0.56304663",
"0.5610067",
"0.56046456",
"0.5602921",
"0.55821... | 0.6866169 | 0 |
The path used after confirmation. | def after_confirmation_path_for(resource_name, resource)
'/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_confirmation_path_for(resource_name, resource)\n root_path\n end",
"def after_confirmation_path_for(resource_name, resource) \n send(\"edit_#{resource.class.name.underscore}_path\",resource)\n end",
"def after_confirmation_path_for(resource_name, resource)\n current_dreamer ? account_dream... | [
"0.66349876",
"0.6573877",
"0.6555062",
"0.65253043",
"0.6417593",
"0.64080113",
"0.6401703",
"0.63872176",
"0.6336483",
"0.6322352",
"0.6284309",
"0.6257149",
"0.6255734",
"0.6243767",
"0.6235097",
"0.6198236",
"0.6198236",
"0.6198236",
"0.618294",
"0.618294",
"0.618294",
... | 0.66043603 | 1 |
We only want to be able write a 'name' to the class when the class is 'instantiated' | def initialize(name)
@name = name
@transactions = [ ]
addtransaction("Beggining balance", 0.00)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @name = name\n end",
"def initialize(name)\n @name = name #initialize any name\n @@all << self # pushing class into class variable\n end",
"def append_class(name); end",
"def append_class(name); end",
"def initialize name\n @name = name\nend",
"def name #use and initlizer to ... | [
"0.7006427",
"0.6978709",
"0.6959472",
"0.6959472",
"0.69211197",
"0.6901204",
"0.6898694",
"0.6868788",
"0.68578815",
"0.6840619",
"0.6790834",
"0.67635053",
"0.67635053",
"0.6756377",
"0.67373675",
"0.6718981",
"0.66858524",
"0.6679505",
"0.66757065",
"0.6628029",
"0.662665... | 0.0 | -1 |
Calculate the balance based off of all of the transactions that exist within the account. We do this by writing a method called `balance`. Use 'each' method to iterate over the transactions using a 'do' block | def balance
balance = 0.00
@transactions.each do |transaction|
balance += transaction[:amount]
end
return balance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance\n balance = 0.00\n @transactions.each do | transaction|\n balance += transaction[:amount]\n end\n return balance\n end",
"def balance\n # accounts.reduce(0) {|sum, account| sum + account.balance}\n accounts.sum {|account| account.balance}\n\n # total = 0\n ... | [
"0.807822",
"0.8018403",
"0.79845005",
"0.7948886",
"0.7895782",
"0.78477263",
"0.780683",
"0.7769322",
"0.76587546",
"0.76009876",
"0.7558565",
"0.751756",
"0.7411776",
"0.7401691",
"0.7399176",
"0.7356269",
"0.73426634",
"0.7307166",
"0.7198905",
"0.7197284",
"0.7195446",
... | 0.79057163 | 4 |
Define a 'to_s' method in order to 'concatenate' the bank accoount balance in the format you awnt along with the bank account name and other details... | def to_s
puts "Bank Account:\t#{name}\n"
puts "Your current balance is:\t#{sprintf("%0.2f", balance)} USD"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n\t\t puts \"\\nEnding balance:\\nBank Account Name:\\t#{name}\\nBalance:\\t#{balance}\"\n\tend",
"def to_s\n\t\t\"Name: #{name}, Balance: #{sprintf(\"%0.2f\", balance)}\"\n\tend",
"def to_s\n \"Name: #{name}, Balance: #{sprintf(\"%0.2f\", balance)}\"\n end",
"def to_s\n result = ''\n ... | [
"0.8387256",
"0.8211498",
"0.8142312",
"0.80810595",
"0.7642276",
"0.763269",
"0.76272583",
"0.76263815",
"0.7613711",
"0.7538851",
"0.7439019",
"0.7424171",
"0.73892504",
"0.73821694",
"0.72408557",
"0.72372615",
"0.7201159",
"0.7172068",
"0.7138719",
"0.7118348",
"0.711187"... | 0.85379815 | 0 |
'to_s' method on 'BankAccount' class which displays 'name' and 'balance' | def to_s
puts "\nEnding balance:\nBank Account Name:\t#{name}\nBalance:\t#{balance}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n\t\t puts \"Bank Account:\\t#{name}\\n\"\n\t\t puts \"Your current balance is:\\t#{sprintf(\"%0.2f\", balance)} USD\" \n\tend",
"def to_s\n\t\t\"Name: #{name}, Balance: #{sprintf(\"%0.2f\", balance)}\"\n\tend",
"def to_s\n \"Name: #{name}, Balance: #{sprintf(\"%0.2f\", balance)}\"\n end",
"def ... | [
"0.80699104",
"0.7577288",
"0.75023204",
"0.7444449",
"0.73321867",
"0.71332973",
"0.7087377",
"0.70392287",
"0.7020604",
"0.70132804",
"0.68980277",
"0.68922263",
"0.6856051",
"0.6836574",
"0.68342745",
"0.68336177",
"0.6822332",
"0.6816008",
"0.67968047",
"0.67473096",
"0.6... | 0.79877377 | 1 |
get input by input id | def by_id(id)
@client.request(:get, "/system/inputs/#{id}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(id)\n data = @app.client.input id\n Clarinet::Input.new @app, data[:input]\n end",
"def set_input\n @input = Input.find(params[:id])\n end",
"def set_input\n @input = Input.find(params[:id])\n end",
"def set_input\n @input = Input.find(params[:id])\n end",
"def ... | [
"0.6733807",
"0.638527",
"0.638527",
"0.638527",
"0.638527",
"0.63661367",
"0.6301012",
"0.6256747",
"0.6204041",
"0.6074685",
"0.6043859",
"0.5946688",
"0.59248525",
"0.5852758",
"0.58381486",
"0.5776141",
"0.5753593",
"0.57388073",
"0.5669311",
"0.56363434",
"0.5632858",
... | 0.7148867 | 0 |
object for get information about input types | def types
@types ||= Types.new(@client)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_type; end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def types; end",
"def get_input_types(env, receiver)\n inputs.map{|input| get_type(env, input, receiver)}\n end",
"def type_params; end",
"def type_params; end",
"def type_params; end",
"d... | [
"0.7672311",
"0.73917496",
"0.73917496",
"0.73917496",
"0.73917496",
"0.73917496",
"0.717092",
"0.71236235",
"0.71236235",
"0.71236235",
"0.71236235",
"0.71236235",
"0.693242",
"0.688652",
"0.6863926",
"0.6653785",
"0.6562337",
"0.6513826",
"0.649411",
"0.6492718",
"0.6424513... | 0.0 | -1 |
convert type name to type | def type_name_to_type(params)
type = types.name_to_type(params[:type_name])
params[:type] = type
params.delete(:type_name)
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_type(type_name)\n type_name.constantize\n end",
"def compute_type(type_name)\n type_name_with_module(type_name).split(\"::\").inject(Object) do |final_type, part| \n final_type = final_type.const_get(part)\n end\n end",
"def to_type_name(name, namespa... | [
"0.78128463",
"0.7454727",
"0.72121674",
"0.7013237",
"0.6991987",
"0.6944398",
"0.6943773",
"0.6919847",
"0.68339336",
"0.68222433",
"0.68083346",
"0.6799456",
"0.6799456",
"0.6794315",
"0.67682964",
"0.67156035",
"0.67073476",
"0.6696575",
"0.6661605",
"0.66540474",
"0.6652... | 0.7729922 | 1 |
Round a number to a specific decimal place. | def round_to(decimal_places)
to_f.round(decimal_places)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round_to(decimal_places)\n (self * 10**decimal_places).round.to_f / 10**decimal_places\n end",
"def round_float(float, places); end",
"def round(number, precision)\n ((number * 10**precision).round.to_f) / (10**precision)\n end",
"def round(float, decimal_places)\n sprintf(\"%.#{decima... | [
"0.78908336",
"0.7612533",
"0.7508967",
"0.72463775",
"0.7228234",
"0.7209074",
"0.71764493",
"0.710768",
"0.70920944",
"0.69875723",
"0.6935608",
"0.688703",
"0.68320155",
"0.6830204",
"0.6829868",
"0.67793876",
"0.6665382",
"0.6662287",
"0.6660315",
"0.66397274",
"0.6581806... | 0.8062596 | 0 |
SNMP walking routine, with some added features delay after higher number of queries | def dowalk(mngr,query)
rows = Array.new
count = 0
query.each do |oid|
start_oid = SNMP::ObjectId.new(oid)
next_oid = start_oid
while next_oid.subtree_of?(start_oid)
begin
response = mngr.get_next(next_oid)
varbind = response.varbind_list.first
rescue
puts "[-] error while quering for #{next_oid}"
break
end
break if not varbind.oid.subtree_of?(start_oid)
next_oid = varbind.oid
count += 1
# need to make below values as variables
# we don't want to cause high CPU on the devices
rows.push(varbind.value)
if count >= 100
sleep 0.1
puts "[!] query count reached first limit - slowing down" if count == 100
end
if count >= 1000
puts "[!] query count reached second limit - stopping"
break
end
end
end
rows
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_snmp\n\n # onvide le tableau des résultats précédents\n @deltas.clear\n # var temporaire pour détecter le changement de valeur d'index dans la liste de résultats\n tmp_index = ''\n\n # requête SNMP get :\n # la requête renvoie une ligne par index, cette ligne peut être in ou out,\n # l... | [
"0.60458696",
"0.5830391",
"0.5748571",
"0.5390206",
"0.5268302",
"0.5173195",
"0.5167503",
"0.51394403",
"0.5131706",
"0.51232564",
"0.5115241",
"0.51023436",
"0.5062055",
"0.5061355",
"0.50398415",
"0.50072736",
"0.49784082",
"0.49765942",
"0.4960694",
"0.49400786",
"0.4923... | 0.6307447 | 0 |
this simple transform should match the basic ActiveRecord::Result format for db results. | def as_hash
as_json.with_indifferent_access.tap do |rec|
rec.transform_values! do |value|
if value.is_a?(Time) || value.is_a?(DateTime)
ymdhms = value.utc.strftime("%Y-%m-%d %H:%M:%S")
subseconds = value.utc.strftime(".%6N").to_f.to_s.sub(/^0\./, "")
"#{ymdhms}.#{subseconds}"
else
value.as_json
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_result(result)\n end",
"def run(result)\r\n\t\t\r\n\t\tcolumn_names = Array.new #store the column names\r\n\t\tfields = result.fetch_fields #get all the fields\r\n\t\tfields.each do |field|\r\n\t\t\tcolumn_names << field.name #push a field into the coumn_names\r\n\t\tend\r\n\t\t\r\n\t\trow_cou... | [
"0.65641856",
"0.63239527",
"0.6277784",
"0.625738",
"0.6240135",
"0.6147244",
"0.6090655",
"0.60887426",
"0.6047224",
"0.6002277",
"0.58922297",
"0.5813438",
"0.5788314",
"0.57540905",
"0.57431394",
"0.5714857",
"0.571229",
"0.57055676",
"0.5686092",
"0.56828535",
"0.5672716... | 0.0 | -1 |
GET /tipo_filtros/1 GET /tipo_filtros/1.xml | def show
@tipo_filtro = TipoFiltro.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @tipo_filtro }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tipo_filtro = TipoFiltro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_filtro }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_recibo }\n end\n ... | [
"0.6745605",
"0.67398536",
"0.67234206",
"0.66814137",
"0.6667591",
"0.6607687",
"0.6565387",
"0.65368515",
"0.6532929",
"0.65316063",
"0.65131414",
"0.6459779",
"0.6449398",
"0.6445603",
"0.64389354",
"0.64235866",
"0.6374168",
"0.6371245",
"0.63584244",
"0.63544554",
"0.634... | 0.74712145 | 0 |
GET /tipo_filtros/new GET /tipo_filtros/new.xml | def new
@tipo_filtro = TipoFiltro.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @tipo_filtro }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tipo_contrato = TipoContrato.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_contrato }\n end\n end",
"def new\n @filtro_vehiculo = FiltroVehiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n form... | [
"0.7308088",
"0.7290275",
"0.7287951",
"0.72796077",
"0.72324795",
"0.719996",
"0.71888715",
"0.71723896",
"0.71500176",
"0.7144853",
"0.7112831",
"0.71056485",
"0.70973086",
"0.7060862",
"0.70558125",
"0.70540124",
"0.7034022",
"0.7032434",
"0.70183146",
"0.6988104",
"0.6984... | 0.8075629 | 0 |
POST /tipo_filtros POST /tipo_filtros.xml | def create
@tipo_filtro = TipoFiltro.new(params[:tipo_filtro])
respond_to do |format|
if @tipo_filtro.save
format.html { redirect_to(@tipo_filtro, :notice => 'TipoFiltro was successfully created.') }
format.xml { render :xml => @tipo_filtro, :status => :created, :location => @tipo_filtro }
else
format.html { render :action => "new" }
format.xml { render :xml => @tipo_filtro.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tipo_filtro = TipoFiltro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_filtro }\n end\n end",
"def show\n @tipo_filtro = TipoFiltro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format... | [
"0.6420355",
"0.5801892",
"0.5782677",
"0.5694712",
"0.55748594",
"0.5571271",
"0.5567292",
"0.551429",
"0.54913956",
"0.54646015",
"0.5461918",
"0.54501",
"0.5439359",
"0.5402195",
"0.5397931",
"0.5374148",
"0.5367078",
"0.53659004",
"0.53622544",
"0.5349792",
"0.5334668",
... | 0.6709314 | 0 |
PUT /tipo_filtros/1 PUT /tipo_filtros/1.xml | def update
@tipo_filtro = TipoFiltro.find(params[:id])
respond_to do |format|
if @tipo_filtro.update_attributes(params[:tipo_filtro])
format.html { redirect_to(@tipo_filtro, :notice => 'TipoFiltro was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @tipo_filtro.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\... | [
"0.61366814",
"0.60394704",
"0.58904153",
"0.5867853",
"0.5830976",
"0.5829597",
"0.58077526",
"0.5791402",
"0.57527536",
"0.57435465",
"0.572947",
"0.57198524",
"0.5707464",
"0.5693535",
"0.5682523",
"0.5680805",
"0.56547993",
"0.5631448",
"0.5630538",
"0.5624189",
"0.561658... | 0.6699857 | 0 |
DELETE /tipo_filtros/1 DELETE /tipo_filtros/1.xml | def destroy
@tipo_filtro = TipoFiltro.find(params[:id])
@tipo_filtro.destroy
respond_to do |format|
format.html { redirect_to(tipo_filtros_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n @tipo_de_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_de_documento_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n ... | [
"0.6612702",
"0.65706843",
"0.65391517",
"0.65311044",
"0.6518119",
"0.650598",
"0.6465929",
"0.6457107",
"0.6448614",
"0.6426289",
"0.64213353",
"0.6415037",
"0.6414201",
"0.6405483",
"0.6399571",
"0.6369957",
"0.63579535",
"0.63555914",
"0.6340907",
"0.63392705",
"0.6312520... | 0.7250184 | 0 |
Poorlynamed Campaign class resolver | def to_dripper
::Caffeinate.dripper_collection.resolve(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def campaign; Campaign.get(self.campaign_id); end",
"def campaign; Campaign.get(self.campaign_id); end",
"def campaign\n self.class.caffeinate_campaign\n end",
"def campaign\n company.campaign\n end",
"def get_instance(payload)\n CampaignInstance.new(@version, payload, )\n ... | [
"0.6217579",
"0.6217579",
"0.6168188",
"0.59303385",
"0.5925029",
"0.58026165",
"0.578407",
"0.57034653",
"0.5524107",
"0.5405422",
"0.5388858",
"0.5387513",
"0.5356889",
"0.5327237",
"0.5300465",
"0.5260212",
"0.52580214",
"0.525724",
"0.5195405",
"0.5191416",
"0.5183479",
... | 0.477122 | 75 |
Checks to see if the subscriber exists. | def subscriber(record, **args)
caffeinate_campaign_subscriptions.find_by(subscriber: record, **args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriber?(dbname = nil)\n subscriptions(dbname).any?\n end",
"def subscribes?(record, **args)\n subscriber(record, **args).present?\n end",
"def subscriber?(email_address)\n !subscriber(email_address).nil?\n end",
"def has_subscriber?(user_id)\r\n self.subscribers.inclu... | [
"0.752799",
"0.7265319",
"0.7247807",
"0.72218466",
"0.7192678",
"0.717307",
"0.71017206",
"0.70467633",
"0.69650894",
"0.69126356",
"0.6858322",
"0.68511486",
"0.68400955",
"0.6779897",
"0.67339826",
"0.6685595",
"0.6673168",
"0.6670017",
"0.6616324",
"0.6607828",
"0.657627"... | 0.0 | -1 |
Check if the subscriber exists | def subscribes?(record, **args)
subscriber(record, **args).present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriber?(dbname = nil)\n subscriptions(dbname).any?\n end",
"def subscribe(subscriber)\n if @id != subscriber.getId\n @subscriptions[subscriber.getId] = subscriber\n return true\n end\n return false\n end",
"def has_subscriber?(user_id)\r\n self.subscribers.include?(... | [
"0.76956147",
"0.75955653",
"0.738231",
"0.7326496",
"0.7294988",
"0.72285485",
"0.7193556",
"0.7128194",
"0.71240765",
"0.7092888",
"0.7079508",
"0.7030331",
"0.6951858",
"0.6916984",
"0.6901865",
"0.68792534",
"0.68007535",
"0.676771",
"0.6763353",
"0.6757027",
"0.6744197",... | 0.74806 | 2 |
Unsubscribes an object from a campaign. Campaign[:onboarding].unsubscribe(Company.first, user: Company.first.admin, reason: "Because I said so") is the same as Campaign.find_by(slug: "onboarding").caffeinate_campaign_subscriptions.find_by(subscriber: Company.first, user: Company.first.admin).unsubscribe!("Because I said so") Just... mintier. | def unsubscribe(subscriber, **args)
reason = args.delete(:reason)
subscription = subscriber(subscriber, **args)
return false if subscription.nil?
subscription.unsubscribe(reason)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe\n CampaignMonitorWrapper.unsubscribe(user.email)\n end",
"def unsubscribe!(reason = nil)\n update!(unsubscribed_at: ::Caffeinate.config.time_now, unsubscribe_reason: reason)\n\n caffeinate_campaign.to_dripper.run_callbacks(:on_unsubscribe, self)\n end",
"def unsubscribe(email)\... | [
"0.74581206",
"0.72047496",
"0.6987216",
"0.6811801",
"0.67727804",
"0.67360365",
"0.67302924",
"0.67221355",
"0.66860914",
"0.665698",
"0.66358405",
"0.6624739",
"0.6591913",
"0.6588627",
"0.65824723",
"0.65746903",
"0.6573805",
"0.6522745",
"0.6502448",
"0.6489009",
"0.6464... | 0.61395293 | 63 |
Creates a `CampaignSubscription` object for the present Campaign. Allows passing `args` to delegate additional arguments to the record. Uses `find_or_create_by`. | def subscribe(subscriber, **args)
caffeinate_campaign_subscriptions.find_or_create_by(subscriber: subscriber, **args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe!(subscriber, **args)\n caffeinate_campaign_subscriptions.find_or_create_by!(subscriber: subscriber, **args)\n end",
"def create_subscription!(plan, coupon, params)\n subscription = find_or_build_subscription(plan, coupon, params)\n subscription.save_with_payment!\n return subscript... | [
"0.75296235",
"0.64149314",
"0.63212955",
"0.60824597",
"0.6034721",
"0.5917424",
"0.58482075",
"0.5841959",
"0.57585114",
"0.5746375",
"0.5724394",
"0.57079816",
"0.5707246",
"0.56818575",
"0.56723",
"0.56309414",
"0.5626865",
"0.55641526",
"0.556065",
"0.5556583",
"0.554798... | 0.75935745 | 0 |
Subscribes an object to a campaign. Raises `ActiveRecord::RecordInvalid` if the record was invalid. | def subscribe!(subscriber, **args)
caffeinate_campaign_subscriptions.find_or_create_by!(subscriber: subscriber, **args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe(subscriber, **args)\n caffeinate_campaign_subscriptions.find_or_create_by(subscriber: subscriber, **args)\n end",
"def subscribe\n CampaignMonitorWrapper.subscribe(id: user.id, email: user.email, name: user.name, beta: user.beta?.to_s, billable: user.billable?.to_s)\n end",
"def subsc... | [
"0.64265466",
"0.6350889",
"0.59259635",
"0.58669853",
"0.57175565",
"0.56955796",
"0.55729085",
"0.55360806",
"0.55061877",
"0.5476807",
"0.54680187",
"0.5466731",
"0.5453503",
"0.5406475",
"0.53934467",
"0.53436077",
"0.5328871",
"0.5306146",
"0.5300841",
"0.5298906",
"0.52... | 0.6347455 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.