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 |
|---|---|---|---|---|---|---|
Put backquote in front of crucial characters | def dequote(in_string)
in_string.gsub(/[$,"\\\n]/) {|x| "\\"+x}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requote(value) return restore_ends(value, '\"') end",
"def escape_quotes(unfiltered)\n unfiltered.to_s.gsub(/'/, \"''\")\n end",
"def qesc(s)\n s.gsub(\"'\", \"''\")\nend",
"def _quoteString ( str )\n str.gsub( /\\\\/, '\\&\\&' ).gsub( /'/, \"''\" ) # ' (for ruby-mode)\n end",
... | [
"0.77381307",
"0.7003321",
"0.68669194",
"0.681717",
"0.67351776",
"0.6669662",
"0.6633347",
"0.6620168",
"0.6601471",
"0.6572463",
"0.654746",
"0.65407354",
"0.6539323",
"0.6532504",
"0.6509874",
"0.6505717",
"0.6491979",
"0.648449",
"0.6461159",
"0.6461159",
"0.6461159",
... | 0.60359836 | 93 |
Strip leading and trailing whitespace | def strip_whitespace
self.url = url.strip rescue ''
self.explicit_refspec = explicit_refspec.strip rescue ''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end",
"def strip_leading_whitespace(text)\n return text if text.empty?\n leadin... | [
"0.8021187",
"0.79838777",
"0.7959773",
"0.78956157",
"0.7775048",
"0.77323127",
"0.7660412",
"0.7628947",
"0.7580976",
"0.7565837",
"0.75448084",
"0.7543182",
"0.75327295",
"0.7481093",
"0.74383956",
"0.7429741",
"0.7405567",
"0.7389328",
"0.7346857",
"0.734037",
"0.72765994... | 0.0 | -1 |
Check format of refspec | def validate_refspec
begin
valid_git_refspec_path?(explicit_refspec)
rescue => e
errors.add(:explicit_refspec, e.message)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_git_refspec?(refspec)\n refspec.match(GIT_REFSPEC_REGEX)\n end",
"def validate_gemspec; end",
"def valid_gemspec?; end",
"def validate(ref_name)\n not_allowed_prefixes = %w(refs/heads/ refs/remotes/ -)\n return false if ref_name.start_with?(*not_allowed_prefixes)\n return false i... | [
"0.7634264",
"0.6585689",
"0.6480538",
"0.63305",
"0.6256705",
"0.60151297",
"0.59479856",
"0.59479856",
"0.59479856",
"0.5900144",
"0.58977306",
"0.586551",
"0.58257085",
"0.58159834",
"0.5685376",
"0.56827205",
"0.5572799",
"0.5551575",
"0.550738",
"0.5500304",
"0.54869676"... | 0.7281103 | 1 |
Validate a Git SSH urls | def valid_git_ssh_url?(url)
url.match(GIT_SSH_URL_REGEX)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def git_url_must_be_valid\n matched = false\n\n [/^https?:\\/\\/.+\\.git$/i, /^git@.+:.+\\.git$/i].each do |valid_form|\n if valid_form.match git_url\n matched = true\n break\n end\n end\n\n unless matched\n errors.add(:git_url, 'must be of form http[s]://host/path/to/repos... | [
"0.80382884",
"0.7494356",
"0.67685974",
"0.6469758",
"0.64237416",
"0.63534147",
"0.6352756",
"0.63049835",
"0.62823087",
"0.6242235",
"0.621529",
"0.6212526",
"0.61539316",
"0.61320907",
"0.6125146",
"0.60870737",
"0.6063904",
"0.60533315",
"0.6048245",
"0.6045237",
"0.6045... | 0.8440473 | 0 |
Validate a Git refspec [+]: [+]refs//:refs// GIT_REFSPEC_REGEX = /\A\+?([^:])(:([^:]))?\z/ | def valid_git_refspec?(refspec)
refspec.match(GIT_REFSPEC_REGEX)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_refspec\n begin\n valid_git_refspec_path?(explicit_refspec)\n rescue => e\n errors.add(:explicit_refspec, e.message)\n end\n end",
"def valid_refspec_path?(refspec)\n !refspec || refspec == '' || parse_refspec(refspec) ? true : false\n end",
"def validate(ref_name)\n n... | [
"0.74208856",
"0.6419382",
"0.6360152",
"0.6356998",
"0.5620991",
"0.55655235",
"0.5505946",
"0.547096",
"0.5430591",
"0.53878546",
"0.53277755",
"0.53088284",
"0.5228049",
"0.5225696",
"0.52102226",
"0.51929605",
"0.51921016",
"0.5188488",
"0.5184116",
"0.51330084",
"0.50591... | 0.79908866 | 0 |
Allow null or empty components | def valid_refspec_path?(refspec)
!refspec || refspec == '' || parse_refspec(refspec) ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty()\n \n end",
"def not_empty!(*args)\n if args.any?{|arg| arg.nil? or arg.to_s.empty?}\n coercion_error!\n end\n args\n end",
"def effectively_empty( value )\n value.nil? || value.to_s.empty?\n end",
"def is_empty?\n end",
... | [
"0.63970834",
"0.633438",
"0.62710434",
"0.61425763",
"0.6133463",
"0.6041666",
"0.6041666",
"0.60091186",
"0.5993046",
"0.59828436",
"0.59771365",
"0.5943053",
"0.59361565",
"0.59213",
"0.59213",
"0.59213",
"0.59213",
"0.59213",
"0.59213",
"0.59213",
"0.59213",
"0.59213",
... | 0.0 | -1 |
Parse a reference component. Two possibilities: 1) refs/type/name 2) name | def parse_refspec(spec)
parsed_refspec = spec.match(REF_COMPONENT_REGEX)
return nil if parsed_refspec.nil?
if parsed_refspec[1]
# Should be first class. If no type component, return fail
if parsed_refspec[3]
{ type: parsed_refspec[3], name: parsed_refspec[4] }
else
nil
end
elsif parsed_refspec[3]
{ type: nil, name: "#{parsed_refspec[3]}/#{parsed_refspec[4]}" }
else
{ type: nil, name: parsed_refspec[4] }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parts_of_reference (docset, ref_str)\n\tref = ref_str.split\n\tif ref.length != 2\n\t\tTextMate.exit_show_tool_tip \"Cannot parse reference: #{str}\"\n\tend\n\n\tlanguage, type, klass, thing = ref[0].split('/')\n\tRef.new(docset, language, type, klass, thing, ref[1])\nend",
"def component_reference\n # ... | [
"0.7027189",
"0.65883344",
"0.6315223",
"0.6203796",
"0.59370536",
"0.5904405",
"0.58219314",
"0.58185077",
"0.5750216",
"0.56840336",
"0.5617649",
"0.5593436",
"0.55749047",
"0.5569696",
"0.5558918",
"0.55410755",
"0.55352235",
"0.5485166",
"0.54585737",
"0.54434454",
"0.541... | 0.78108215 | 0 |
////////////////////////////////////////////////////////////////////////// Properties ////////////////////////////////////////////////////////////////////////// Set of the user control visibility | def visible=(visible)
@visible = visible
@cImage.visible = visible
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visible=(vis)\n if vis\n show\n else\n hide\n end\n end",
"def visible=(visible)\n @visible = visible\n for i in 0 .. @ucControls.size-1\n @ucControls[i].visible = visible\n end\n end",
"def visible=(visibility)\n end",
"def visible=(bool)\n ... | [
"0.725057",
"0.715895",
"0.7083419",
"0.6959489",
"0.69367146",
"0.69367146",
"0.6829695",
"0.67854863",
"0.6764412",
"0.6728918",
"0.66418266",
"0.6640898",
"0.66404456",
"0.6627523",
"0.6609199",
"0.65964514",
"0.65940666",
"0.6546558",
"0.6520928",
"0.6510744",
"0.6403504"... | 0.6366749 | 23 |
Set of the user control activity | def active=(active)
@active = active
@cImage.active = active
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_user_activity\n @user_activity = UserActivity.find(params[:id])\n end",
"def set_user_activity\n @user_activity = UserActivity.find(params[:id])\n end",
"def set_user_activity\n @user_activity = UserActivity.find(params[:id])\n end",
"def set_user_activity\n @user_activit... | [
"0.6543812",
"0.6543812",
"0.6543812",
"0.6543812",
"0.636757",
"0.6331631",
"0.62381357",
"0.622229",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59626406",
"0.59... | 0.0 | -1 |
////////////////////////////////////////////////////////////////////////// Constructors ////////////////////////////////////////////////////////////////////////// Object Initialization window : window in which the control will be drawn image : name of the image in Cache.picture align : background image alignment opacity : background image opacity valign : background image vertical alignment active : control activity visible : control visibility | def initialize(window, image, align=0, opacity=255, valign=0, active=true, visible=true)
super(active, visible)
self.image = image
@cImage = CImage.new(window, Rect.new(0, 0, window.width, window.height),
nil, nil, align, opacity, valign, active, visible)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(actor)\n super(Combo_Window_Settings[0], Combo_Window_Settings[1], Combo_Window_Settings[2], Combo_Window_Settings[3])\n self.contents = Bitmap.new(width - 32, height - 32)\n self.z = 4000\n @combo_page = 0\n @max_size = ((self.width - 32) / 52).to_i\n if Combo_Window_Bg != nil\n ... | [
"0.7140153",
"0.6880777",
"0.6833494",
"0.6740844",
"0.66967905",
"0.6687944",
"0.6615173",
"0.6612384",
"0.64079523",
"0.6341161",
"0.6303596",
"0.615773",
"0.61414814",
"0.61060673",
"0.60875916",
"0.60066813",
"0.59810704",
"0.5975251",
"0.59717256",
"0.5956071",
"0.589799... | 0.74796516 | 0 |
////////////////////////////////////////////////////////////////////////// Public Methods ////////////////////////////////////////////////////////////////////////// Draw the background image on the window | def draw()
if self.image != nil
bitmap = Cache.picture(self.image)
@cImage.img_bitmap = bitmap
@cImage.src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
@cImage.draw()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_background\n @background.draw\n end",
"def draw_background\n\t\tcolor = self.colour_scheme.background\t\n\t\t@canvas.new_image(@canvas_width, @canvas_height) { self.background_color = color }\n\tend",
"def draw_background\n Gosu.draw_rect(0, 0, 1000, 700, @background, ZOrder::BACKGROUND, mode=... | [
"0.81973857",
"0.81378835",
"0.8053062",
"0.789294",
"0.773947",
"0.76038134",
"0.7596194",
"0.7561345",
"0.7546212",
"0.7372357",
"0.7358918",
"0.73348624",
"0.7295203",
"0.7199637",
"0.71928895",
"0.7183833",
"0.7025411",
"0.695291",
"0.6885535",
"0.68232393",
"0.6783896",
... | 0.0 | -1 |
This Boardprint method is given for free and does not need to be modified It is used to make your game playable. | def print
@stacks.each { |stack| p stack }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_board\n\t\tputs \"GAME BOARD AT TIME: #{@current_turn}\"\n\t\tprint full_game_board.map{|c| c.join(\"\")}.join(\"\\n\")\n\tend",
"def print_board\n puts \"\\n[#{@spaces[1]}][#{@spaces[2]}][#{@spaces[3]}]\\n[#{@spaces[4]}][#{@spaces[5]}][#{@spaces[6]}]\\n[#{@spaces[7]}][#{@spaces[8]}][#{@spaces[9]}]\... | [
"0.7558168",
"0.74995106",
"0.7419121",
"0.7382993",
"0.73380345",
"0.7308744",
"0.7292794",
"0.7261575",
"0.7251224",
"0.72454286",
"0.7226249",
"0.72082895",
"0.719844",
"0.7180073",
"0.7172382",
"0.7153194",
"0.7150651",
"0.71344894",
"0.71186835",
"0.7101451",
"0.7099203"... | 0.0 | -1 |
comment has no user_id | def test_01_comment_on_post_as_unregistered_user
published_post = Post.published.first
post :create, {:post_id => published_post.id }
assert_not_nil assigns['post']
comment = assigns['comment']
assert_not_nil comment
assert comment.errors['user_name']
assert comment.errors['user_email']
assert comment.errors['body']
# now a successful comment
post :create, {:post_id => published_post.id,
:comment => {
:user_name => 'El Rug',
:user_email => 'elurg@example.com',
:body => 'Very nice. Whatever.'
}}
assert_not_nil assigns['post']
comment = assigns['comment']
assert comment.errors.empty?
assert_equal false, comment.published?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_want_notified_new_comment user_eject\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND users.mail_comments = ? AND users.id != ?\", \n self.id, \n true, \n user_eject.id)\n .collect { |l| l.user }\n end",
"def add... | [
"0.690646",
"0.6878028",
"0.6849248",
"0.6833303",
"0.6759081",
"0.67547745",
"0.67137176",
"0.6664328",
"0.6633982",
"0.64892286",
"0.648777",
"0.64758795",
"0.64752275",
"0.64308465",
"0.64157987",
"0.6399419",
"0.6384165",
"0.633936",
"0.63352036",
"0.6315776",
"0.63078594... | 0.5889517 | 73 |
must update user attributes comment must have user_id comment must show up on post unless it's marked as spam | def test_02_comment_on_post_as_guest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n params[:comment][:user_id]= current_user\n \n @comment=@post.comments.find(params[:id])\n \n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.html { redirect_to([@blog,@post], :notice => 'Post was successfully updated.') }\n format.xml... | [
"0.65451944",
"0.65294504",
"0.64585066",
"0.63818955",
"0.63593227",
"0.6357558",
"0.62625563",
"0.6227534",
"0.62039506",
"0.61980426",
"0.6182508",
"0.61361754",
"0.61339885",
"0.6129209",
"0.6124243",
"0.61223435",
"0.61197555",
"0.61193013",
"0.61052686",
"0.60733074",
"... | 0.0 | -1 |
comment must have user_id comment must skip spamcheck if user is moderator comment must show up on post unless it's marked as spam | def test_03_comment_on_post_as_member
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_comment?(user) \n # for now, we allow everyone\n return true \n end",
"def spam_check\n CommentSpamCheckWorker.perform_in(5.seconds, id)\n end",
"def comment_moderation(user_id, comment_id, url_title, response)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Co... | [
"0.7010616",
"0.68067414",
"0.6707428",
"0.6690456",
"0.662083",
"0.64736736",
"0.64639485",
"0.6441988",
"0.64373755",
"0.6390721",
"0.6315077",
"0.6279278",
"0.6205962",
"0.6182887",
"0.61715144",
"0.61646914",
"0.6125215",
"0.6101237",
"0.6079182",
"0.6046708",
"0.60342026... | 0.0 | -1 |
GET /prescription_rows GET /prescription_rows.json | def index
@prescription_rows = PrescriptionRow.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n @rows\n end",
"def rows\n render 'rows.html'\n end",
"def rows\r\n @all_rows\r\n end",
"def rows\n return @rows if @rows\n if execute && result['rows']\n ... | [
"0.6478178",
"0.6422939",
"0.6422939",
"0.6422939",
"0.6280199",
"0.61504316",
"0.6112614",
"0.60659045",
"0.6045267",
"0.6002428",
"0.5982811",
"0.5894429",
"0.587916",
"0.5870322",
"0.58657676",
"0.58511263",
"0.583577",
"0.5819273",
"0.5818478",
"0.57955325",
"0.5757333",
... | 0.72599727 | 0 |
GET /prescription_rows/1 GET /prescription_rows/1.json | def show
@products=Product.where("id<?",100000000)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @prescription_rows = PrescriptionRow.all\n end",
"def set_prescription_row\n @prescription_row = PrescriptionRow.find(params[:id])\n end",
"def show_row\n @dataset = Dataset.find(params[:dataset_id])\n if params[:row_id].gsub(/[0-9]/,\"\").length == 0 #il n'y a que des chiffres\n ... | [
"0.71127987",
"0.63060755",
"0.62820715",
"0.61719143",
"0.6120837",
"0.6033352",
"0.6033352",
"0.6033352",
"0.602832",
"0.59287435",
"0.58512247",
"0.58153886",
"0.57445663",
"0.571086",
"0.5702518",
"0.56980884",
"0.565374",
"0.56497526",
"0.5636128",
"0.56186014",
"0.55117... | 0.0 | -1 |
POST /prescription_rows POST /prescription_rows.json | def create
@prescription_row = PrescriptionRow.new(prescription_row_params)
@prescription=Prescription.where(id: @prescription_row.id_prescription).first
respond_to do |format|
if @prescription_row.save
format.html { redirect_to @prescription, notice: 'Prescription row was successfully created.' }
format.json { render :show, status: :created, location: @prescription_row }
else
format.html { render :new }
format.json { render json: @prescription_row.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @prescription_rows = PrescriptionRow.all\n end",
"def prescription_row_params\n params.require(:prescription_row).permit(:id_prescription, :id_product, :dose_per_ha)\n end",
"def set_prescription_row\n @prescription_row = PrescriptionRow.find(params[:id])\n end",
"def create\n... | [
"0.64642286",
"0.6381454",
"0.62451756",
"0.5641393",
"0.54272866",
"0.5425547",
"0.54190195",
"0.5292091",
"0.52874905",
"0.527435",
"0.5249497",
"0.5248934",
"0.5202156",
"0.51881605",
"0.5184491",
"0.5170243",
"0.51695687",
"0.5143078",
"0.51152897",
"0.5106153",
"0.509552... | 0.65303224 | 0 |
PATCH/PUT /prescription_rows/1 PATCH/PUT /prescription_rows/1.json | def update
@prescription=Prescription.where(id: @prescription_row.id_prescription).first
respond_to do |format|
if @prescription_row.update(prescription_row_params)
format.html { redirect_to @prescription, notice: 'Prescription row was successfully updated.' }
format.json { render :show, status: :ok, location: @prescription_row }
else
format.html { render :edit }
format.json { render json: @prescription_row.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @invoice_row.update(invoice_row_params)\n format.html { redirect_to @invoice_row, notice: 'Invoice row was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { ren... | [
"0.62912524",
"0.62644726",
"0.61803424",
"0.61260873",
"0.61047447",
"0.60863405",
"0.59917754",
"0.59543204",
"0.59264123",
"0.58878165",
"0.58099526",
"0.5801209",
"0.57682484",
"0.5762273",
"0.5759523",
"0.57157946",
"0.56973946",
"0.5637743",
"0.56302476",
"0.5628837",
"... | 0.7086263 | 0 |
DELETE /prescription_rows/1 DELETE /prescription_rows/1.json | def destroy
@prescription=Prescription.where(id: @prescription_row.id_prescription).first
@prescription_row.destroy
respond_to do |format|
format.html { redirect_to @prescription, notice: 'Prescription row was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end",
"def destroy\n @invoice_row.destroy\n respond_to do |format|\n format.html { redirect_to invoice_rows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aquizitions_row.destroy\n respond... | [
"0.71572876",
"0.69639033",
"0.67276305",
"0.6638447",
"0.66364783",
"0.64451736",
"0.6415882",
"0.63976604",
"0.63940984",
"0.637693",
"0.63256764",
"0.63192636",
"0.6314287",
"0.6287831",
"0.6281609",
"0.6280975",
"0.623191",
"0.6223048",
"0.62212116",
"0.61885625",
"0.6177... | 0.74570113 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_prescription_row
@prescription_row = PrescriptionRow.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def prescription_row_params
params.require(:prescription_row).permit(:id_prescription, :id_product, :dose_per_ha)
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 |
Holds errors Helper functions Print installation errors | def print_errors
puts "
#{"== #{"Ruby 2D Installation Errors".error} =======================================\n"}
#{$errors.join("\n ")}\n
#{"======================================================================"}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error\n %i[error fatal]\n end",
"def print_error\n puts @error_text if @error_text\n print_usage\n end",
"def error!\n # Unhandled exception\n if @exception\n exception_message\n exit 2\n # Some checksums did not match?\n elsi... | [
"0.6542539",
"0.6495752",
"0.6468784",
"0.634068",
"0.63373524",
"0.6313754",
"0.62557095",
"0.6193081",
"0.6193081",
"0.6193081",
"0.6193081",
"0.6193081",
"0.6193081",
"0.6193081",
"0.6193081",
"0.6193081",
"0.61435694",
"0.61435694",
"0.61435694",
"0.61435694",
"0.6118537"... | 0.7611388 | 0 |
Add compiler and linker flags | def add_flags(type, flags)
case type
when :c
$CFLAGS << " #{flags} "
when :ld
$LDFLAGS << " #{flags} "
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_codethink_compiler_flags(platform, env = {}, opts = {})\n env = with_standard_compiler_flags(env = env, opts = opts)\n\n compiler_flags =\n {\n \"LDFLAGS\" => \"-Wl,-rpath,#{install_dir}/lib -L#{install_dir}/lib\",\n \"CFLAGS\" => \"-I#{install_dir}/include -O2\",\n }\n\n return env.mer... | [
"0.7464435",
"0.7435028",
"0.7435028",
"0.74102515",
"0.7306684",
"0.7043461",
"0.6994468",
"0.6994468",
"0.6927209",
"0.69249994",
"0.68824506",
"0.681252",
"0.681252",
"0.66168875",
"0.6523334",
"0.6417647",
"0.6320798",
"0.625107",
"0.6206574",
"0.6126276",
"0.61206603",
... | 0.78256524 | 0 |
Check for SDL libraries | def check_sdl
unless have_library('SDL2') && have_library('SDL2_image') && have_library('SDL2_mixer') && have_library('SDL2_ttf')
$errors << "Couldn't find packages needed by Ruby 2D."
case $platform
when :linux, :linux_rpi
# Fedora and CentOS
if system('which yum')
$errors << "Install the following packages using `yum` (or `dnf`) and try again:\n" <<
" SDL2-devel SDL2_image-devel SDL2_mixer-devel SDL2_ttf-devel".bold
# Arch
elsif system('which pacman')
$errors << "Install the following packages using `pacman` and try again:\n" <<
" sdl2 sdl2_image sdl2_mixer sdl2_ttf".bold
# openSUSE
elsif system('which zypper')
$errors << "Install the following packages using `zypper` and try again:\n" <<
" libSDL2-devel libSDL2_image-devel libSDL2_mixer-devel libSDL2_ttf-devel".bold
# Ubuntu, Debian, and Mint
# `apt` must be last because openSUSE has it aliased to `zypper`
elsif system('which apt')
$errors << "Install the following packages using `apt` and try again:\n" <<
" libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev".bold
end
when :bsd
$errors << "Install the following packages using `pkg` and try again:\n" <<
" sdl2 sdl2_image sdl2_mixer sdl2_ttf".bold
end
$errors << "" << "See #{"ruby2d.com".bold} for additional help."
print_errors; exit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sdl_linux\n unless have_library('SDL2') && have_library('SDL2_image') && have_library('SDL2_mixer') && have_library('SDL2_ttf')\n\n $errors << \"Couldn't find packages needed by Ruby 2D.\"\n\n # Fedora and CentOS\n if system('which yum')\n $errors << \"Install the following packages using ... | [
"0.75101244",
"0.6577883",
"0.59941566",
"0.5817426",
"0.5780352",
"0.5749494",
"0.5727793",
"0.5706594",
"0.56945014",
"0.5687077",
"0.56557924",
"0.5634598",
"0.56057364",
"0.5604998",
"0.56046486",
"0.5551067",
"0.55303794",
"0.55233276",
"0.5504533",
"0.5498461",
"0.54745... | 0.75856405 | 0 |
Set Raspberry Pi flags | def set_rpi_flags
if $platform == :linux_rpi
add_flags(:c, '-I/opt/vc/include')
add_flags(:ld, '-L/opt/vc/lib -lbrcmGLESv2')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gpioinit yabm\n yabm.gpiosetdat(1 << 3 | 1 << 4)\nend",
"def flags=(flags)\n if FFI::Libmagic.magic_setflags(_cookie, flags) < 0\n raise(FlagError, lasterror())\n end\n end",
"def gpioinit yabm\n yabm.gpiosetdir(1 << 3)\n\n yabm.gpiosetdat(1 << 3)\nend",
"def gpioinit yabm\n yabm.gpiosetd... | [
"0.6221178",
"0.6176925",
"0.61387813",
"0.607874",
"0.6037413",
"0.5983555",
"0.59487313",
"0.5934318",
"0.5931134",
"0.5824487",
"0.581541",
"0.5718183",
"0.57058525",
"0.5688689",
"0.56842667",
"0.56607956",
"0.56399626",
"0.5625288",
"0.5603252",
"0.5586855",
"0.55577344"... | 0.6792887 | 0 |
Set flags for Linux and BSD | def set_linux_bsd_flags
check_sdl
set_rpi_flags
add_flags(:ld, "-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm")
if $RUBY2D_PLATFORM == :linux then add_flags(:ld, '-lGL') end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flags=(flags)\n if FFI::Libmagic.magic_setflags(_cookie, flags) < 0\n raise(FlagError, lasterror())\n end\n end",
"def setCFlags(flags) @CFLAGS = ensureArray(flags) end",
"def default_flags\n cflags = []\n\n # GCC on Solaris 10 produces 32-bit code by default, so add -m64\n # when runn... | [
"0.63164806",
"0.6221122",
"0.60628366",
"0.6018642",
"0.6018642",
"0.60154915",
"0.60154915",
"0.6011904",
"0.5856891",
"0.5809496",
"0.5737225",
"0.56775504",
"0.56628144",
"0.55844355",
"0.5582342",
"0.5576389",
"0.55530214",
"0.55296576",
"0.55072",
"0.5481024",
"0.547902... | 0.6671238 | 0 |
Use SDL and other libraries installed by the user (not those bundled with the gem) | def use_usr_libs
case $RUBY2D_PLATFORM
when :macos
add_flags(:c, `sdl2-config --cflags`)
add_flags(:c, '-I/opt/homebrew/include')
add_flags(:ld, `sdl2-config --libs`)
add_flags(:ld, '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf')
add_flags(:ld, '-Wl,-framework,OpenGL')
when :windows
add_flags(:ld, '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf')
add_flags(:ld, '-lopengl32 -lglew32')
when :linux_rpi
set_linux_bsd_flags
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sdl\n unless have_library('SDL2') && have_library('SDL2_image') && have_library('SDL2_mixer') && have_library('SDL2_ttf')\n\n $errors << \"Couldn't find packages needed by Ruby 2D.\"\n\n case $platform\n when :linux, :linux_rpi\n # Fedora and CentOS\n if system('which yum')\n $... | [
"0.72636074",
"0.7177546",
"0.65676486",
"0.5915895",
"0.5732897",
"0.5659674",
"0.55819476",
"0.5578892",
"0.5544047",
"0.5476818",
"0.5441917",
"0.5438415",
"0.53864264",
"0.532199",
"0.5143635",
"0.5131231",
"0.511447",
"0.5024887",
"0.49879977",
"0.49680218",
"0.4966454",... | 0.717555 | 2 |
Convert hex to base64 | def challenge1(s)
Utils::Base64.encode(s.dup.extend(Utils::HexString).to_ascii)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hex_to_base64(s)\n [[s].pack(\"H*\")].pack('m*')\nend",
"def hex_to_bin_to_base64(hex_encoded_string)\n bin = Lib.hex_to_bin(hex_encoded_string)\n Lib.bin_to_base64([bin])\nend",
"def hex_to_64(str)\n decoded_hex = hex_to_ascii(str) \n Base64.strict_encode64 decoded_hex\n end",
"def hex_base6... | [
"0.7892829",
"0.77233034",
"0.7678519",
"0.7380503",
"0.72973937",
"0.6983626",
"0.6915366",
"0.6901798",
"0.68894464",
"0.65773594",
"0.65773594",
"0.65570974",
"0.6552694",
"0.6552694",
"0.65489215",
"0.6521358",
"0.65151256",
"0.650481",
"0.64614403",
"0.64484346",
"0.6448... | 0.5980409 | 42 |
Detect singlecharacter XOR (input file is comprised of hexstrings) | def challenge4(file)
file.each_line.map(&:chomp).map(&method(:challenge3)).min_by(&Cryptanalysis::Frequency.method(:english_score))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookForXOR(fileName)\n cryptoLines = IO.readlines(fileName)\n \n cryptoLines.each do |c|\n breakXORCipher c.strip\n end\nend",
"def singleByteXOR(hexStr, keyChar)\n #ASCII character -> 1 byte of binary (8 bit) -> 2-digit hex\n hexKeyChar = binToHex(decToBin(keyChar.ord).rjust(8, '0')... | [
"0.74655145",
"0.71622455",
"0.7069354",
"0.6729107",
"0.64458436",
"0.6351249",
"0.63330376",
"0.6314325",
"0.62621135",
"0.6259225",
"0.6197536",
"0.61805004",
"0.61482364",
"0.6147524",
"0.60609925",
"0.59599817",
"0.5952924",
"0.59441954",
"0.59263295",
"0.59152",
"0.5906... | 0.0 | -1 |
Implement repeatingkey XOR (input is ASCII and output is a hexstring) | def challenge5(s, k)
Utils::HexString.from_bytes(CryptUtil.xor(s.bytes, k))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeat_key_xor(text, key)\n\thex_text = text.unpack('H*').join\n\t#Unpack the key into its individual letters\n\tkey_array = key.unpack('H2H2H2')\n\tout = hex_text.scan(/../).map.with_index { |a, i| fixed_xor(a, key_array[i.modulo(3)]) }.join\nend",
"def repeating_key_xor(string, key)\n counter = 0\n e... | [
"0.8466317",
"0.81003916",
"0.7928955",
"0.78872114",
"0.76600856",
"0.75364554",
"0.7451826",
"0.7380779",
"0.73735905",
"0.732157",
"0.7267711",
"0.7228373",
"0.7209144",
"0.7194506",
"0.7117138",
"0.70786875",
"0.70493245",
"0.7047851",
"0.7013655",
"0.7006161",
"0.6996673... | 0.6012667 | 74 |
AES in ECB mode (input is Base64 encoded) | def challenge7(file, key)
CryptUtil.aes_128_ecb(Utils::Base64.decode(file.read), key, :decrypt)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aes_ecb_internal(mode, buffer, key)\n raise 'Buffer must be composed of 16-byte chunks' unless (buffer.size % 16).zero?\n cipher = OpenSSL::Cipher.new('AES-128-ECB')\n cipher.send(mode)\n cipher.key = key.pack('C*')\n cipher.padding = 0 # decryption will otherwise fail\n result = cipher.update(buffer.pac... | [
"0.77014667",
"0.71870446",
"0.70953625",
"0.7003191",
"0.69431645",
"0.6899073",
"0.67459005",
"0.6734289",
"0.6719244",
"0.6707872",
"0.66260886",
"0.6619251",
"0.6618523",
"0.66005147",
"0.6530729",
"0.65197456",
"0.6417432",
"0.6412459",
"0.6406471",
"0.6399043",
"0.63535... | 0.0 | -1 |
Detect AES in ECB mode (ECB is stateless, so can be sussed out by noticing repeated blocks) | def challenge8(file)
file.each_line.map(&:chomp).to_a.max_by do |line|
ciphertext = line.extend(Utils::HexString).to_ascii
blocks = (0...ciphertext.length).map { |i| ciphertext[i, 16] }
blocks.map { |s| blocks.count(s) }.max
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ecb_encrypted?(cipher)\n line_parts = cipher.scan(/.{16}/)\n line_parts.detect { |e| line_parts.count(e) > 1 } ? true : false\nend",
"def detect_ecb_or_cbc(black_box)\n plain = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n ecb_encrypted?(black_box.call(... | [
"0.6914897",
"0.69069684",
"0.6795968",
"0.66165334",
"0.6568053",
"0.5842149",
"0.57817006",
"0.57639927",
"0.57294613",
"0.56371236",
"0.56302017",
"0.55807835",
"0.54920465",
"0.54208106",
"0.5408473",
"0.5378903",
"0.5320392",
"0.53027666",
"0.52589643",
"0.52496934",
"0.... | 0.0 | -1 |
Interpolates the Image_URI with the "multiverse id". | def image_uri_from_id= id
self.image_uri = Image_URI % id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_image_uri row\n row./('td[2]/a').first[:href] =~ /multiverseid=(\\d+)/\n $1\n end",
"def image_uri\n return \"/image_store/#{id}.#{image_type}\"\n end",
"def uri(image)\n image.dig('medium', 'uri')\n end",
"def server_image_id(s)\n s.respond_to?('image_id') ? s.im... | [
"0.6982181",
"0.6027198",
"0.5883056",
"0.5785005",
"0.5686432",
"0.5496292",
"0.54169875",
"0.5276519",
"0.52235425",
"0.5202247",
"0.5182692",
"0.51750237",
"0.516498",
"0.51522064",
"0.512283",
"0.50873554",
"0.50715446",
"0.50608474",
"0.5059086",
"0.503886",
"0.5034896",... | 0.6443549 | 1 |
The most recent rarity of this card. | def rarity
self.sets.first[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_recent_recipe\n recipe_cards.last\n end",
"def most_recent_recipe\n self.recipe_cards.sort do |recipe_card|\n recipe_card.date\n end.first\n end",
"def most_recent_recipe\n self.recipecards.max_by{|recipecard| recipecard.date}.recipe\n end",
"def most_recent_recip... | [
"0.6986351",
"0.65454805",
"0.6493216",
"0.6412613",
"0.6387238",
"0.6382523",
"0.6264759",
"0.6220972",
"0.61437535",
"0.61038345",
"0.6101156",
"0.60983294",
"0.6033237",
"0.6030501",
"0.6021791",
"0.6008673",
"0.6004816",
"0.5997525",
"0.59605414",
"0.5938334",
"0.59274685... | 0.6511575 | 2 |
The most recent set this card appeared in. | def set
self.sets.first[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_set\n match_sets.last\n end",
"def last\r\n\t\t@set.last\r\n\tend",
"def most_recent_recipe\n recipe_cards.last\n end",
"def topMostCard\n object.cards.mostRecentlyUpdated.one[0]\n end",
"def most_recent\n self.stats.first\n end",
"def latest\n self\n end",
"def most_re... | [
"0.7558938",
"0.71380925",
"0.6808984",
"0.676779",
"0.65960115",
"0.6458018",
"0.6437813",
"0.6324888",
"0.63213724",
"0.6307577",
"0.62337464",
"0.6200927",
"0.61918",
"0.6189313",
"0.61602825",
"0.61494035",
"0.6147676",
"0.6136807",
"0.6133241",
"0.6133241",
"0.6117776",
... | 0.6270748 | 10 |
Set the power and toughness from an Array. | def pow_tgh=(pt)
return if pt.nil?
self.pow = pt[0]
self.tgh = pt[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_hand=(array)\n @my_hand = array\n end",
"def **(power)\n\tself.class.new(@units.inject({}) {|h,(unit,exponent)| h[unit] = power * exponent; h })\n end",
"def power_araray(array)\n ## recorrer el arreglo con map\n ## hacer la operatorio con ** 2\n ## map entrega un copia lista\nend",
"def va... | [
"0.602114",
"0.5796425",
"0.5495514",
"0.54485124",
"0.54485124",
"0.5431977",
"0.5369213",
"0.5281939",
"0.5274408",
"0.5242032",
"0.52373946",
"0.52162546",
"0.52104753",
"0.5205909",
"0.51795554",
"0.51616263",
"0.51427215",
"0.51003534",
"0.50852215",
"0.5081546",
"0.5081... | 0.50644916 | 23 |
Operator method to determine equality. Does an `==` comparison on each attribute of the Card objects. All must be equal for true. | def == other_card
if self.name == other_card.name and
self.cost == other_card.cost and
self.sets == other_card.sets and
self.image_uri == other_card.image_uri and
self.multiverse_id == other_card.multiverse_id and
self.text == other_card.text and
self.flavour_text == other_card.flavour_text and
self.types == other_card.types and
self.loyalty == other_card.loyalty and
self.artist == other_card.artist and
self.number == other_card.number
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other_card)\n return false if other_card.nil?\n\n [:suit, :value].all? do |attr|\n self.send(attr) == other_card.send(attr)\n end\n end",
"def ==(other)\n other.is_a?(Card) && value == other.value && suit == other.suit\n end",
"def eql?(card)\n rank == card.rank && suit == card.sui... | [
"0.712284",
"0.6982151",
"0.6844561",
"0.67349494",
"0.67269784",
"0.6657298",
"0.66326267",
"0.6602563",
"0.65976346",
"0.65598583",
"0.65147555",
"0.6502785",
"0.63980275",
"0.63892823",
"0.63845843",
"0.636712",
"0.6335557",
"0.6283563",
"0.6281177",
"0.6280543",
"0.626904... | 0.6859679 | 2 |
Calculate and format totals properly | def it_totals
qty = params[:qty].to_f / 10000
total = params[:total].to_f / 10000
tbl = params[:tbl]
# Format output values
qty = number_with_precision(qty.round(4), precision: 4)
total = number_with_precision(total.round(4), precision: 4)
# Setup JSON hash
@json_data = { "qty" => qty.to_s, "tbl" => tbl.to_s, "total" => total.to_s }
render json: @json_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total\n apply_rules(subtotal).round\n end",
"def total\n '%.2f' % calculate_total\n end",
"def overall_total\n puts \"Portfolio Total: $#{sprintf('%.2f', @all_totals)}\"\n end",
"def totals_table\n strings = []\n strings << \"#{@labels[:subtotal]}:\"\n strings << @document.subt... | [
"0.743445",
"0.73362035",
"0.7321094",
"0.7236359",
"0.7170506",
"0.7164925",
"0.7038644",
"0.70297277",
"0.700823",
"0.7000019",
"0.69825894",
"0.6971217",
"0.6962173",
"0.69585896",
"0.69493216",
"0.69437635",
"0.6940885",
"0.69122905",
"0.68928874",
"0.6889542",
"0.6888616... | 0.0 | -1 |
Update inventory transfer number at view (generate_code_btn) | def it_generate_no
store = params[:store]
# Builds no, if possible
code = store == '$' ? '$err' : it_next_no(store)
@json_data = { "code" => code }
render json: @json_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_number\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Set quantity input window to inactive / invisible\r\n @number_window.active = false\r\n @number_window.visible = false\r\n ... | [
"0.57784945",
"0.5753739",
"0.56634957",
"0.5623948",
"0.561712",
"0.5562932",
"0.55309904",
"0.5528236",
"0.54995096",
"0.5487453",
"0.54749745",
"0.54643685",
"0.5441968",
"0.5432359",
"0.542775",
"0.5415374",
"0.54058105",
"0.53849757",
"0.5382497",
"0.5369485",
"0.5369333... | 0.0 | -1 |
Update stocks & average price at view from product & store | def it_update_from_product_store
product = params[:product]
store = params[:store]
tbl = params[:tbl]
initial_stock = 0
current_stock = 0
# company = nil
# product_company_price = nil
average_price = 0
if product != '0' && store != '0'
stock = Stock.find_by_product_and_store(product, store)
# Stocks
initial_stock = stock.initial rescue 0
current_stock = stock.current rescue 0
# WAP
average_price = product_average_price(product, store)
end
# Format numbers
initial_stock = number_with_precision(initial_stock.round(4), precision: 4)
current_stock = number_with_precision(current_stock.round(4), precision: 4)
average_price = number_with_precision(average_price.round(4), precision: 4)
# Setup JSON hash
@json_data = { "initial" => initial_stock.to_s, "stock" => current_stock.to_s,
"tbl" => tbl.to_s, "average_price" => average_price.to_s }
render json: @json_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def of_update_description_prices_from_product_store\n product = params[:product]\n store = params[:store]\n supplier = params[:supplier]\n tbl = params[:tbl]\n description = \"\"\n qty = 0\n price = 0\n discount_p = 0\n discount = 0\n code = \"\"\n amount = 0\... | [
"0.689524",
"0.6801746",
"0.6789446",
"0.67554986",
"0.6738091",
"0.66344637",
"0.66309196",
"0.65732765",
"0.65387034",
"0.65283996",
"0.6526053",
"0.6459753",
"0.63988125",
"0.63988125",
"0.6389891",
"0.6374579",
"0.6365551",
"0.63528717",
"0.6349857",
"0.6305951",
"0.63026... | 0.7533274 | 0 |
Update product & store selects at view from organization | def it_update_from_organization
organization = params[:org]
if organization != '0'
@organization = Organization.find(organization)
@stores = @organization.blank? ? stores_dropdown : @organization.stores.order(:name)
@products = @organization.blank? ? products_dropdown : @organization.products.order(:product_code)
else
@stores = stores_dropdown
@products = products_dropdown
end
# Products array
@products_dropdown = products_array(@products)
# Setup JSON
@json_data = { "store" => @stores, "product" => @products_dropdown }
render json: @json_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def of_update_product_select_from_organization\n organization = params[:org]\n if organization != '0'\n @organization = Organization.find(organization)\n @products = @organization.blank? ? products_dropdown : @organization.products.order(:product_code)\n else\n @products = produ... | [
"0.73574847",
"0.7326221",
"0.7295935",
"0.72786015",
"0.7248016",
"0.71485144",
"0.6912485",
"0.6815768",
"0.6769088",
"0.66692615",
"0.66400737",
"0.6601307",
"0.659989",
"0.65947556",
"0.6519945",
"0.6480212",
"0.6477955",
"0.64766115",
"0.646362",
"0.64620316",
"0.6461407... | 0.72082275 | 5 |
Update product select at view from organization select | def it_update_product_select_from_organization
organization = params[:org]
if organization != '0'
@organization = Organization.find(organization)
@products = @organization.blank? ? products_dropdown : @organization.products.order(:product_code)
else
@products = products_dropdown
end
# Products array
@products_dropdown = products_array(@products)
# Setup JSON
@json_data = { "product" => @products_dropdown }
render json: @json_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def of_update_product_select_from_organization\n organization = params[:org]\n if organization != '0'\n @organization = Organization.find(organization)\n @products = @organization.blank? ? products_dropdown : @organization.products.order(:product_code)\n else\n @products = produ... | [
"0.8060184",
"0.7999927",
"0.79585665",
"0.7221268",
"0.64361227",
"0.6406823",
"0.6406236",
"0.6206396",
"0.6206323",
"0.6147343",
"0.61380434",
"0.61150837",
"0.60537827",
"0.6042138",
"0.60393804",
"0.59883505",
"0.59611905",
"0.5950808",
"0.5942775",
"0.5939708",
"0.59297... | 0.79976434 | 2 |
Default Methods GET /inventory_transfers GET /inventory_transfers.json | def index
manage_filter_state
no = params[:No]
store = params[:Store]
# OCO
init_oco if !session[:organization]
# Initialize select_tags
@stores = stores_dropdown if @stores.nil?
# Arrays for search
current_stores = @stores.blank? ? [0] : current_stores_for_index(@stores)
# If inverse no search is required
no = !no.blank? && no[0] == '%' ? inverse_no_search(no) : no
@search = InventoryTransfer.search do
with :outbound_store_id, current_stores
fulltext params[:search]
if session[:organization] != '0'
with :organization_id, session[:organization]
end
if !no.blank?
if no.class == Array
with :count_no, no
else
with(:count_no).starting_with(no)
end
end
if !store.blank?
with :outbound_store_id, store
end
data_accessor_for(InventoryTransfer).include = [:store]
order_by :sort_no, :desc
paginate :page => params[:page] || 1, :per_page => per_page
end
@inventory_transfers = @search.results
respond_to do |format|
format.html # index.html.erb
format.json { render json: @inventory_transfers }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transfers\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/transfers/list').transfers\n end",
"def index\n @transfers = Transfer.all\n end",
"def index\n @transfers = Transfer.all\n end",
"def index\n @transf... | [
"0.74772704",
"0.68863165",
"0.68863165",
"0.68863165",
"0.68863165",
"0.6858125",
"0.6840665",
"0.6758058",
"0.6742206",
"0.6694599",
"0.6618191",
"0.65992063",
"0.65295506",
"0.64710164",
"0.6464923",
"0.6380194",
"0.63447124",
"0.6317432",
"0.6214609",
"0.61991495",
"0.618... | 0.6009678 | 25 |
GET /inventory_transfers/1 GET /inventory_transfers/1.json | def show
@breadcrumb = 'read'
@inventory_transfer = InventoryTransfer.find(params[:id])
@items = @inventory_transfer.inventory_transfer_items.paginate(:page => params[:page], :per_page => per_page).order('id')
# Approvers
@is_approver = company_approver(@inventory_transfer, @inventory_transfer.store.company, current_user.id) ||
office_approver(@inventory_transfer, @inventory_transfer.store.office, current_user.id) ||
(current_user.has_role? :Approver)
# If current user is not approver up to here, maybe it's a multioffice store...
if !@is_approver
@is_approver = multioffice_store_approver(@inventory_transfer, current_user.id)
end
respond_to do |format|
format.html # show.html.erb
format.json { render json: @inventory_transfer }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_inventory_transfer(transfer_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/inventory/transfers/{transfer_id}',\n 'default')\n .template_param(new_parameter(tran... | [
"0.71039265",
"0.69563454",
"0.685632",
"0.68320984",
"0.68034744",
"0.6588655",
"0.6588655",
"0.6588655",
"0.6588655",
"0.6515545",
"0.65058887",
"0.6505851",
"0.6389067",
"0.6330638",
"0.6239513",
"0.61622685",
"0.61614466",
"0.60975146",
"0.6082874",
"0.6014826",
"0.600193... | 0.6046088 | 19 |
GET /inventory_transfers/new GET /inventory_transfers/new.json | def new
@breadcrumb = 'create'
@inventory_transfer = InventoryTransfer.new
@stores = stores_dropdown
@products = products_dropdown
respond_to do |format|
format.html # new.html.erb
format.json { render json: @inventory_transfer }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @breadcrumb = 'create'\n @inventory_transfer = InventoryTransfer.new(params[:inventory_transfer])\n @inventory_transfer.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @inventory_transfer.save\n format.html { redirect_to @inventory... | [
"0.7427209",
"0.7287815",
"0.71444964",
"0.71320796",
"0.70536536",
"0.68514395",
"0.6834122",
"0.68336666",
"0.6769565",
"0.6769565",
"0.6769565",
"0.6753339",
"0.67140967",
"0.66713244",
"0.6639242",
"0.66195375",
"0.6590691",
"0.65712583",
"0.65573925",
"0.6516378",
"0.651... | 0.77238226 | 0 |
POST /inventory_transfers POST /inventory_transfers.json | def create
@breadcrumb = 'create'
@inventory_transfer = InventoryTransfer.new(params[:inventory_transfer])
@inventory_transfer.created_by = current_user.id if !current_user.nil?
respond_to do |format|
if @inventory_transfer.save
format.html { redirect_to @inventory_transfer, notice: crud_notice('created', @inventory_transfer) }
format.json { render json: @inventory_transfer, status: :created, location: @inventory_transfer }
else
@stores = stores_dropdown
format.html { render action: "new" }
format.json { render json: @inventory_transfer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @transfer = Transfer.new(transfer_params)\n\n if @transfer.save\n render json: @transfer, status: :created, location: @transfer\n else\n render json: @transfer.errors, status: :unprocessable_entity\n end\n end",
"def transfer_inventory(reason)\n packaging.product.transfer... | [
"0.6524708",
"0.6476213",
"0.6467632",
"0.6466285",
"0.6404008",
"0.63641465",
"0.6289076",
"0.62709284",
"0.6130198",
"0.61248016",
"0.6024871",
"0.60058075",
"0.59673405",
"0.59650016",
"0.59515566",
"0.59353155",
"0.59302783",
"0.59180164",
"0.5896658",
"0.5883729",
"0.588... | 0.66746795 | 0 |
PUT /inventory_transfers/1 PUT /inventory_transfers/1.json | def update
@breadcrumb = 'update'
@inventory_transfer = InventoryTransfer.find(params[:id])
items_changed = false
if params[:inventory_transfer][:inventory_transfer_items_attributes]
params[:inventory_transfer][:inventory_transfer_items_attributes].values.each do |new_item|
current_item = InventoryTransferItem.find(new_item[:id]) rescue nil
if ((current_item.nil?) || (new_item[:_destroy] != "false") ||
((current_item.product_id.to_i != new_item[:product_id].to_i) ||
(current_item.quantity.to_f != new_item[:quantity].to_f)))
items_changed = true
break
end
end
end
master_changed = false
if ((params[:inventory_transfer][:transfer_date].to_date != @inventory_transfer.transfer_date) ||
(params[:inventory_transfer][:transfer_no].to_s != @inventory_transfer.transfer_no) ||
(params[:inventory_transfer][:remarks].to_s != @inventory_transfer.remarks) ||
(params[:inventory_transfer][:store_id].to_i != @inventory_transfer.store_id.to_i) ||
(params[:inventory_transfer][:company_id].to_i != @inventory_transfer.company_id.to_i) ||
(params[:inventory_transfer][:organization_id].to_i != @inventory_transfer.organization_id.to_i))
master_changed = true
end
respond_to do |format|
if master_changed || items_changed
@inventory_transfer.updated_by = current_user.id if !current_user.nil?
if @inventory_transfer.update_attributes(params[:inventory_transfer])
format.html { redirect_to @inventory_transfer,
notice: (crud_notice('updated', @inventory_transfer) + "#{undo_link(@inventory_transfer)}").html_safe }
format.json { head :no_content }
else
@stores = stores_dropdown
format.html { render action: "edit" }
format.json { render json: @inventory_transfer.errors, status: :unprocessable_entity }
end
else
format.html { redirect_to @inventory_transfer }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @transfer.update(transfer_params)\n render :show, status: :ok, location: @transfer\n else\n render json: @transfer.errors, status: :unprocessable_entity\n end\n end",
"def transfer\n @inventory_type = InventoryType.find_by_id(params[:id])\n @inventory =Inventory.find_by_... | [
"0.6350137",
"0.6251312",
"0.6052473",
"0.6032178",
"0.6032178",
"0.59995943",
"0.598211",
"0.59718794",
"0.5969915",
"0.5962237",
"0.5900503",
"0.585822",
"0.5766852",
"0.5763733",
"0.57442325",
"0.5732476",
"0.5708102",
"0.5708102",
"0.5708102",
"0.5708102",
"0.5708102",
... | 0.63090754 | 1 |
DELETE /inventory_transfers/1 DELETE /inventory_transfers/1.json | def destroy
@inventory_transfer = InventoryTransfer.find(params[:id])
respond_to do |format|
if @inventory_transfer.destroy
format.html { redirect_to inventory_transfers_url,
notice: (crud_notice('destroyed', @inventory_transfer) + "#{undo_link(@inventory_transfer)}").html_safe }
format.json { head :no_content }
else
format.html { redirect_to inventory_transfers_url, alert: "#{@inventory_transfer.errors[:base].to_s}".gsub('["', '').gsub('"]', '') }
format.json { render json: @inventory_transfer.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @transfer.destroy\n respond_to do |format|\n format.html { redirect_to transfers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transfer = Transfer.find(params[:id])\n @transfer.destroy\n\n respond_to do |format|\n format.html { redirect_to ... | [
"0.73116654",
"0.7265549",
"0.70849764",
"0.706796",
"0.70177186",
"0.70177186",
"0.70177186",
"0.7011757",
"0.70116967",
"0.70042074",
"0.7001087",
"0.69125235",
"0.68209743",
"0.68209743",
"0.6802214",
"0.6794805",
"0.67604595",
"0.6696511",
"0.6694881",
"0.66807944",
"0.66... | 0.71249 | 2 |
Can't edit or delete when => User isn't administrator => Order is approved | def cannot_edit(_t)
!session[:is_administrator] && !_t.approver_id.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cannot_edit(_order)\n !session[:is_administrator] && _order.id < 6\n end",
"def cannot_edit(_order)\n !session[:is_administrator] && _order.id < 5\n end",
"def cannot_edit(_order)\n !session[:is_administrator] && _order.id < 5\n end",
"def can_he_edit?(order)\n (order.author?(c... | [
"0.7708062",
"0.7638661",
"0.7638661",
"0.7225274",
"0.7162144",
"0.69690233",
"0.6862006",
"0.6835654",
"0.6830246",
"0.6830246",
"0.6830246",
"0.68287635",
"0.6826739",
"0.67889136",
"0.67797774",
"0.6768428",
"0.6711885",
"0.6693438",
"0.6679539",
"0.66417086",
"0.66377753... | 0.67904055 | 13 |
Returns _array from _ret table/model filled with _id attribute | def ret_array(_array, _ret, _id)
if !_ret.nil?
_ret.each do |_r|
_array = _array << _r.read_attribute(_id) unless _array.include? _r.read_attribute(_id)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a\n fetch(ids)\n end",
"def to_a\n fetch(ids)\n end",
"def ids\n pluck(:id)\n end",
"def table_array\r\n @table_array\r\n end",
"def load_carrier_array\n @carrier_array = Carrier.all.order(carrier_name: :asc).map { |carrier_array| [carrier_array.carrier_name,... | [
"0.6833078",
"0.6833078",
"0.62377036",
"0.62372637",
"0.61977595",
"0.61723673",
"0.6119777",
"0.6097811",
"0.60205245",
"0.59768695",
"0.59308535",
"0.59194744",
"0.5903594",
"0.58824724",
"0.5878954",
"0.5869129",
"0.5814632",
"0.58134425",
"0.5813334",
"0.5785949",
"0.576... | 0.61435044 | 8 |
Check if store is multioffice, and setup approver based on that | def multioffice_store_approver(ivar, current_user_id)
is_multioffice_approver = false
table = ivar.class.table_name
store_offices = StoreOffice.where(store_id: ivar.store_id)
if !store_offices.blank?
store_offices.each do |o|
notifications = o.office.office_notifications.joins(:notification).where('notifications.table = ? AND office_notifications.role = ? AND office_notifications.user_id = ?', table, 1, current_user_id) rescue nil
if !notifications.blank?
is_multioffice_approver = true
break
end
end
end
is_multioffice_approver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_approver\n if approver == \"1\"\n document.approver = user\n document.save!\n end\n end",
"def need_details?\r\n admin? || purchasing? || popv_admin?\r\n end",
"def allow_multi_install\n refresh\n @allow_multi_install\n end",
"def provided_store_... | [
"0.5939376",
"0.5784085",
"0.57209754",
"0.5718327",
"0.5656137",
"0.5634708",
"0.5602694",
"0.5583373",
"0.5530443",
"0.5510415",
"0.55089",
"0.54645497",
"0.54561245",
"0.54360807",
"0.54239315",
"0.5413922",
"0.54121125",
"0.5410141",
"0.5396888",
"0.5389568",
"0.53861254"... | 0.7243763 | 0 |
Contoller to add new Work | def new
@work = Work.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to action: 'index', flash: {notice: 'Work item was successfully created.' }}\n format.json { render json: @work, status: :created, location: @work }\n else\n format.... | [
"0.7637736",
"0.7483936",
"0.739766",
"0.7375439",
"0.73623115",
"0.73587817",
"0.73587817",
"0.7322821",
"0.7278908",
"0.72702175",
"0.72702175",
"0.70476687",
"0.701793",
"0.7006017",
"0.6990536",
"0.69820696",
"0.6974664",
"0.69570184",
"0.69456965",
"0.69127864",
"0.69035... | 0.6789284 | 26 |
Controller to sav new Work | def create
@work = Work.new(user_params)
if @work.valid?
@work.save
flash[:notice] = 'Successfully added new work details'
redirect_to @work
else
render 'new'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @work = Work.new(work_params\n )\n if save_and_flash(@work)\n redirect_to works_path\n else\n render :new, status: :bad_request\n end\n end",
"def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_... | [
"0.7218522",
"0.718723",
"0.71491313",
"0.70809096",
"0.70403874",
"0.70403874",
"0.70376086",
"0.7031627",
"0.7010105",
"0.6968101",
"0.6968101",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",
"0.6953117",... | 0.61588883 | 86 |
Get deliverable types by lifecycle phase ID Helper method, not intended to be called from outside | def getDeliverableTypes
@projectPhase = ProjectPhase.find(@project_phase_id)
@deliverableTypes = DeliverableType.find_all_by_lifecycle_phase_id(@projectPhase.lifecycle_phase_id)
@deliverableTypesArray = []
@deliverableTypes.each do |type|
@deliverableTypesArray.append([type.name,type.id])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDeliverableTypeList(lifecycle_phase)\n return DeliverableType.find_all_by_lifecycle_phase_id(lifecycle_phase)\n end",
"def project_phase_deliverables\n project_phase_deliverables = []\n stock_deliverable_types.each do |stock|\n stock.deliverables.each do |d|\n project_phase_deliverab... | [
"0.75707686",
"0.65359443",
"0.5847871",
"0.58266044",
"0.5554971",
"0.54890716",
"0.5420633",
"0.54036546",
"0.5343109",
"0.5272584",
"0.5208869",
"0.51857436",
"0.51248497",
"0.51038873",
"0.5099042",
"0.5095878",
"0.50904363",
"0.5066303",
"0.50548416",
"0.50532",
"0.50410... | 0.7535578 | 1 |
GET /env_prefs/1 GET /env_prefs/1.json | def show
@env_pref = EnvPref.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @env_pref }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @env_pref = EnvPref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @env_pref }\n end\n end",
"def update\n @env_pref = EnvPref.find(params[:id])\n\n respond_to do |format|\n if @env_pref.update_attributes(params[:env_pref])\n ... | [
"0.66328526",
"0.6283586",
"0.6240689",
"0.61550695",
"0.6152418",
"0.6059325",
"0.60422677",
"0.5911384",
"0.58494335",
"0.5810558",
"0.5774581",
"0.5774581",
"0.5703879",
"0.56525207",
"0.55767614",
"0.5566981",
"0.55427545",
"0.5490205",
"0.5481879",
"0.5411457",
"0.540801... | 0.733047 | 0 |
GET /env_prefs/new GET /env_prefs/new.json | def new
@env_pref = EnvPref.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @env_pref }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @env_pref = EnvPref.new(params[:env_pref])\n\n respond_to do |format|\n if @env_pref.save\n format.html { redirect_to @env_pref, notice: 'Env pref was successfully created.' }\n format.json { render json: @env_pref, status: :created, location: @env_pref }\n else\n ... | [
"0.7330188",
"0.6307571",
"0.6088916",
"0.5970165",
"0.5953812",
"0.59233856",
"0.5907312",
"0.58819664",
"0.58267313",
"0.5808982",
"0.5807139",
"0.57815534",
"0.5769145",
"0.5761105",
"0.5757839",
"0.5742878",
"0.57225716",
"0.5646083",
"0.5643883",
"0.56200016",
"0.5608949... | 0.8035643 | 0 |
POST /env_prefs POST /env_prefs.json | def create
@env_pref = EnvPref.new(params[:env_pref])
respond_to do |format|
if @env_pref.save
format.html { redirect_to @env_pref, notice: 'Env pref was successfully created.' }
format.json { render json: @env_pref, status: :created, location: @env_pref }
else
format.html { render action: "new" }
format.json { render json: @env_pref.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @env_pref = EnvPref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @env_pref }\n end\n end",
"def update\n @env_pref = EnvPref.find(params[:id])\n\n respond_to do |format|\n if @env_pref.update_attributes(params[:env_pref])\n ... | [
"0.61411256",
"0.59466326",
"0.5854163",
"0.5849115",
"0.58018845",
"0.58012104",
"0.57107455",
"0.5658559",
"0.56441",
"0.5594682",
"0.55498517",
"0.54122823",
"0.5389822",
"0.538783",
"0.5383525",
"0.533814",
"0.5335871",
"0.5304771",
"0.5304771",
"0.53015447",
"0.5298862",... | 0.7136452 | 0 |
PUT /env_prefs/1 PUT /env_prefs/1.json | def update
@env_pref = EnvPref.find(params[:id])
respond_to do |format|
if @env_pref.update_attributes(params[:env_pref])
format.html { redirect_to @env_pref, notice: 'Env pref was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @env_pref.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @env_pref = EnvPref.new(params[:env_pref])\n\n respond_to do |format|\n if @env_pref.save\n format.html { redirect_to @env_pref, notice: 'Env pref was successfully created.' }\n format.json { render json: @env_pref, status: :created, location: @env_pref }\n else\n ... | [
"0.6464932",
"0.63783634",
"0.62679964",
"0.60783887",
"0.5949688",
"0.580463",
"0.5782033",
"0.5775958",
"0.57487935",
"0.5683018",
"0.55604875",
"0.5554317",
"0.5527177",
"0.5509002",
"0.54904646",
"0.5479065",
"0.54733175",
"0.54419583",
"0.5422173",
"0.5422173",
"0.541988... | 0.72722274 | 0 |
DELETE /env_prefs/1 DELETE /env_prefs/1.json | def destroy
@env_pref = EnvPref.find(params[:id])
@env_pref.destroy
respond_to do |format|
format.html { redirect_to env_prefs_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n conf.delete 'dashboard'\n end",
"def destroy\n @user_pref = UserPref.find(params[:id])\n @user_pref.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_prefs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pref.destroy\n respond_to ... | [
"0.6420471",
"0.6366115",
"0.6347137",
"0.62673736",
"0.6235688",
"0.6164056",
"0.6141857",
"0.6094408",
"0.606788",
"0.60486317",
"0.60306364",
"0.6017379",
"0.5992011",
"0.5981826",
"0.5932899",
"0.5932899",
"0.5927974",
"0.5927974",
"0.5927974",
"0.5919517",
"0.5910536",
... | 0.7919139 | 0 |
This method define summary methods. If nothing 'HogeSummary' elements, create and set empty Course::Price instance. result: Coursefare Coursecharge Courseteiki1 ... | def define_summary_method
%w[fare charge teiki1 teiki3 teiki6 teiki12].each do |summary_type|
self.define_singleton_method(summary_type) { price_summary(summary_type) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_summary\n\n products = {}\n products.store(:item_cost, item_cost)\n products.store(:extras_cost, extras_cost)\n\n supplements = {}\n supplements.store(:pick_up_place, pickup_place_cost)\n supplements.store(:return_place, return_place_cost)\n supplements.st... | [
"0.6077154",
"0.5981359",
"0.5981359",
"0.5981359",
"0.5981359",
"0.58317417",
"0.5804441",
"0.58023834",
"0.58023834",
"0.57445705",
"0.5719932",
"0.5715706",
"0.5708237",
"0.56669694",
"0.5637782",
"0.55703855",
"0.55170155",
"0.54754543",
"0.5441314",
"0.54308385",
"0.5430... | 0.7059254 | 0 |
This method relate Course::Route::Line instance to Course::Price instance. If even without those associated with Line, return Price instance. Ex. Course::Route::Linefare Course::Route::Linecharge Course::Route::Lineteiki1 etc... | def relate_line_to_price
@route_list[0].line_list.each do |line|
line.fare = find_price(line, :fare)
line.charge = find_price(line, :charge)
line.teiki1 = find_price(line, :teiki1)
line.teiki3 = find_price(line, :teiki3)
line.teiki6 = find_price(line, :teiki6)
line.teiki12 = find_price(line, :teiki12)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relate_price_to_line\n @price_list.each do |price|\n next unless price.respond_to?(:from_line_index)\n\n price_range = (price.from_line_index.to_i..price.to_line_index.to_i)\n price.line_list = @route_list[0].line_list.select { |line| price_range.include?(line.index.to_i) }\n end... | [
"0.74227226",
"0.6234293",
"0.61065114",
"0.57543975",
"0.5747408",
"0.564146",
"0.55553097",
"0.5442238",
"0.5440147",
"0.5414473",
"0.53995353",
"0.5394653",
"0.5384877",
"0.5384117",
"0.53760713",
"0.5341847",
"0.5270257",
"0.5268172",
"0.52602315",
"0.5257885",
"0.52337",... | 0.80381364 | 0 |
This method relate Course::Price instance to Course::Route::Line instance. It's judged based on to Pricefrom_line_index and Pricefrom_line_index. result: Course::Priceline_list | def relate_price_to_line
@price_list.each do |price|
next unless price.respond_to?(:from_line_index)
price_range = (price.from_line_index.to_i..price.to_line_index.to_i)
price.line_list = @route_list[0].line_list.select { |line| price_range.include?(line.index.to_i) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relate_line_to_price\n @route_list[0].line_list.each do |line|\n line.fare = find_price(line, :fare)\n line.charge = find_price(line, :charge)\n line.teiki1 = find_price(line, :teiki1)\n line.teiki3 = find_price(line, :teiki3)\n line.teiki6 = find_price(line, :teiki6)\n ... | [
"0.79370177",
"0.5991469",
"0.57467395",
"0.56801605",
"0.55621946",
"0.55380714",
"0.548398",
"0.54731184",
"0.5422908",
"0.53979284",
"0.5368188",
"0.5346791",
"0.53339463",
"0.5309887",
"0.52949786",
"0.52005816",
"0.51959795",
"0.5192406",
"0.5192406",
"0.5134198",
"0.512... | 0.8618166 | 0 |
This method relate Course::Price instance and Course::PassStatus instance. It's judged based on to Pricepass_class_index. result: Course::Pricepass_status | def relate_price_and_pass_status
price_list.each do |price|
next unless price.kind.match?(/^Teiki\d{1}$/)
pass_status = find_pass_status(price)
# Price to PassStatus
price.pass_status = pass_status
# PassStatus to Price
pass_status.price_list << price
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @bar = Bar.find(params[:bar_id])\n @pass_set = PassSet.find(params[:id])\n\t @used_passes = @pass_set.passes.order(\"name DESC\").where('redeemed = ?', true).order('passes.reservation_time ASC').paginate(:page => params[:used_passes_page], :per_page => 5)\n\t @unused_passes = @pass_set.passes.or... | [
"0.5139498",
"0.49951208",
"0.49346662",
"0.49056712",
"0.48232698",
"0.47848597",
"0.47768036",
"0.47175533",
"0.47169578",
"0.46846825",
"0.46771947",
"0.46010172",
"0.45770875",
"0.45541218",
"0.45434603",
"0.4530057",
"0.45252088",
"0.4499203",
"0.44837517",
"0.44807866",
... | 0.74869955 | 0 |
change this to :devel to see most messages here (anything without a loglevel as the second arg) | def log(msg, level = :devel)
Log4r::NDC.push("jack_tube")
Log.__send__(level, msg)
Log4r::NDC.pop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(message = \"\", level = 5)\n if $config[:global][:verboselevel] and $config[:global][:verboselevel] >= level\n puts message \n\t\t#logger.info(message)\n Syslog.info(message)\n end\nend",
"def verbose_logging; end",
"def setup_logging( level=:fatal )\n\n\t\t# Only do this when executing from ... | [
"0.67370135",
"0.6651266",
"0.6552499",
"0.64157575",
"0.6387351",
"0.6386957",
"0.6386957",
"0.6144701",
"0.61362046",
"0.61084306",
"0.6070469",
"0.6059245",
"0.6055979",
"0.6046676",
"0.6011606",
"0.6006446",
"0.6006446",
"0.5962687",
"0.5923468",
"0.5913254",
"0.5889674",... | 0.5725147 | 46 |
GET /drivers returns all drivers | def index
respond_with Driver.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_drivers\n return return_all_drivers\n end",
"def get_drivers\n drivers\n end",
"def index\n @drivers = Driver.all\n end",
"def index\n @drivers = Driver.all\n end",
"def index\n @drivers = Driver.all\n\n respond_to do |format|\n format.html # index.html.erb\n for... | [
"0.806816",
"0.7644135",
"0.7608629",
"0.7608629",
"0.7310645",
"0.7310645",
"0.6930903",
"0.68031263",
"0.6726312",
"0.66509604",
"0.66329265",
"0.66294885",
"0.6587495",
"0.647506",
"0.6416417",
"0.6406127",
"0.63996077",
"0.6201205",
"0.6196208",
"0.61698735",
"0.609954",
... | 0.73684937 | 4 |
GET /drivers/:id return's a drivers' json representation | def show
respond_with Driver.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver }\n end\n end",
"def show\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { r... | [
"0.72570795",
"0.72570795",
"0.7071967",
"0.7071967",
"0.6829991",
"0.67943954",
"0.6768278",
"0.67272097",
"0.66713405",
"0.6607007",
"0.64849",
"0.62655693",
"0.62655693",
"0.6240598",
"0.61354756",
"0.6119288",
"0.61132914",
"0.5988234",
"0.5903166",
"0.5859592",
"0.584095... | 0.6789124 | 6 |
POST /drivers creates a new driver | def create
respond_with Driver.create(params[:driver])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # Logic to create a driver and submit to DB\n @driver = Driver.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, locatio... | [
"0.80963695",
"0.7903493",
"0.745262",
"0.71485156",
"0.7124628",
"0.68511593",
"0.6764259",
"0.6659659",
"0.66482055",
"0.6624501",
"0.65894634",
"0.6589225",
"0.6576972",
"0.647909",
"0.6477127",
"0.64479893",
"0.6404491",
"0.6393748",
"0.6335406",
"0.62975055",
"0.6273164"... | 0.8011972 | 1 |
PUT /drivers/:id updates the driver with the specified id | def update
respond_with Driver.update(params[:id],params[:driver])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # Logic to edit a driver and submit to DB\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n ... | [
"0.7231757",
"0.7055115",
"0.70047665",
"0.70047665",
"0.6876922",
"0.68129957",
"0.6519599",
"0.6505081",
"0.63068277",
"0.63068277",
"0.63068277",
"0.63068277",
"0.62743074",
"0.625858",
"0.61862403",
"0.61862403",
"0.6139333",
"0.60568583",
"0.60373247",
"0.6037138",
"0.59... | 0.7577013 | 0 |
DELETE /drivers/:id deletes the driver with the specified id | def destroy
respond_with Driver.destroy(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Logic to delete a record\n @driver = Driver.find(params[:id])\n @driver.destroy... | [
"0.79082227",
"0.76823056",
"0.74744827",
"0.74000967",
"0.74000967",
"0.74000967",
"0.72188294",
"0.7193105",
"0.68836105",
"0.6753138",
"0.6604842",
"0.644768",
"0.6425124",
"0.63896936",
"0.637714",
"0.63718873",
"0.63359296",
"0.62877774",
"0.6229822",
"0.6192193",
"0.615... | 0.7797962 | 1 |
GET /drivers/:id/companies get the companies of a driver | def companies
companies = Driver.find(params[:id]).company
if companies.size == 0
companies = Array.new
end
respond_with companies
rescue ActiveRecord::RecordNotFound
respond_with ActiveRecord::RecordNotFound
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def companies\n\t\tEmpresa.all\n\tend",
"def companies\n signed_get(COMPANIES_PATH)\n end",
"def index\n @companies = ClientCompany.all\n end",
"def all\n endpoint = 'Companies'\n response = JSON.parse(@client.get(endpoint).body)\n companies = response.key?('Items') ? response['Ite... | [
"0.6808417",
"0.6758394",
"0.67520106",
"0.6723108",
"0.6638172",
"0.65025073",
"0.64868593",
"0.6482579",
"0.64729744",
"0.64729744",
"0.64729744",
"0.64729744",
"0.64729744",
"0.64729744",
"0.6419115",
"0.64051986",
"0.64051986",
"0.6369127",
"0.63570654",
"0.634533",
"0.63... | 0.78416586 | 0 |
call Logs all outbound request / responses to VAMF api gateway as :info when success and :warn when fail Semantic logging tags: jti: The "jti" (JWT ID) claim provides a unique identifier for the JWT. status: The HTTP status returned from upstream. duration: The amount of time it took between request being made and response being received in seconds. url: The HTTP Method and URL invoked in the request. | def call(env)
statsd_increment("#{STATSD_KEY_PREFIX}.total", env)
start_time = Time.current
@app.call(env).on_complete do |response_env|
if response_env.status.between?(200, 299)
log(:info, 'VAOS service call succeeded!', log_tags(env, start_time, response_env))
elsif response_env.status == 400 # 400 error resp at times contain PII/PHI so we don't want the err msg logged
statsd_increment("#{STATSD_KEY_PREFIX}.fail", env)
log(:warn, 'VAOS service call failed!', log_tags(env, start_time, response_env))
else
statsd_increment("#{STATSD_KEY_PREFIX}.fail", env)
log(:warn, 'VAOS service call failed!', log_error_tags(env, start_time, response_env))
end
end
rescue Timeout::Error, Faraday::TimeoutError, Faraday::ConnectionFailed => e
statsd_increment("#{STATSD_KEY_PREFIX}.fail", env, e)
log(:warn, "VAOS service call failed - #{e.message}", log_tags(env, start_time))
raise
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __log(method, path, params, body, url, response, json, took, duration)\n logger.info \"#{method.to_s.upcase} #{url} \" +\n \"[status:#{response.status}, request:#{sprintf('%.3fs', duration)}, query:#{took}]\"\n logger.debug \"> #{__convert_to_json(body)}\" if body\n ... | [
"0.72085714",
"0.68570197",
"0.68570197",
"0.67325497",
"0.65774626",
"0.6466217",
"0.6344893",
"0.6299345",
"0.6184078",
"0.6176159",
"0.61657166",
"0.6140161",
"0.6089401",
"0.6065165",
"0.6021518",
"0.5937793",
"0.59206843",
"0.5906571",
"0.5866953",
"0.586544",
"0.5851109... | 0.0 | -1 |
log invokes the Rails.logger | def log(type, message, tags)
Rails.logger.send(type, message, **tags)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log\n end",
"def logger ; @log end",
"def log()\n @log\n end",
"def log\n @log\n end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log\n Engine.logger\n end",
"def log... | [
"0.7998339",
"0.7937285",
"0.7868499",
"0.7839531",
"0.7692226",
"0.7692226",
"0.7692226",
"0.7692226",
"0.7692226",
"0.7692226",
"0.7692226",
"0.7692226",
"0.76788193",
"0.76698565",
"0.7667216",
"0.7635921",
"0.7609944",
"0.7591768",
"0.75241673",
"0.7494665",
"0.7466214",
... | 0.0 | -1 |
decode_jwt_no_sig_check decodes the JWT token received in the response without signature verification | def decode_jwt_no_sig_check(token)
JWT.decode(token, nil, false).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_jwt(jwt)\n #check the headers in post for jwt\n # byebug\n # if auth_header \n # token = cookies.signed[:jwt]\n # auth_header.split(' ')[1]\n begin\n # decode the token, return the decoded part\n JWT.decode(jwt, Rails.a... | [
"0.7797421",
"0.76241046",
"0.7612161",
"0.75176126",
"0.7504962",
"0.7480768",
"0.74780345",
"0.74521583",
"0.7397127",
"0.7390224",
"0.7388958",
"0.73093706",
"0.7287289",
"0.72850204",
"0.7252011",
"0.72235364",
"0.71958894",
"0.7190589",
"0.71817976",
"0.7143333",
"0.7120... | 0.86317235 | 0 |
user_session_request? determines if current request is a user session request | def user_session_request?(env)
env.url.to_s.include?('users/v2/session?processRules=true')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session?\n\t\treturn @session || self.request.session?\n\tend",
"def current_user?\n return session[:user_id] != nil\n end",
"def session?\n session[:user_id]\n end",
"def is_session_user?\n id_or_username = params[:user_id]\n case id_or_username\n # if the id/username is for the curre... | [
"0.76622695",
"0.7621638",
"0.7544766",
"0.7415758",
"0.7398147",
"0.73174095",
"0.72944",
"0.7283349",
"0.727607",
"0.72613263",
"0.72273624",
"0.72168034",
"0.7145939",
"0.7131392",
"0.71289206",
"0.71202534",
"0.7119067",
"0.7119067",
"0.7118152",
"0.71030986",
"0.7078434"... | 0.7875037 | 0 |
jti is the value from the JWT key value pair in the response and needed for logging and audit purposes | def jti(env)
if user_session_request?(env)
decode_jwt_no_sig_check(env.body)['jti']
else
decode_jwt_no_sig_check(x_vamf_headers(env.request_headers))['jti']
end
rescue
'unknown jti'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jwt_subject\n auth0_id_string\n end",
"def payload(id, username)\n {\n exp: (Time.now + 30.minutes).to_i,\n iat: Time.now.to_i,\n iss: ENV['JWT_ISSUER'],\n user: {\n id: id,\n username: username\n }\n }\n end",
"def payload(id, username)... | [
"0.6744525",
"0.65849125",
"0.65849125",
"0.65814745",
"0.64421386",
"0.6348845",
"0.6348845",
"0.63441765",
"0.628879",
"0.6273029",
"0.6111902",
"0.6102883",
"0.6085786",
"0.60713667",
"0.6035578",
"0.60196286",
"0.60168153",
"0.6002532",
"0.6002532",
"0.595924",
"0.5944431... | 0.7777161 | 0 |
x_vamf_headers identifies which XVamfHeader was set and returns the appropriate header value | def x_vamf_headers(request_headers)
request_headers['X-Vamf-Jwt'] || request_headers['X-VAMF-JWT']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header_value\n return @header_value\n end",
"def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end",
"def header name\n headers.each_pair do |header_name, header_value|\n if header_name.downcase == name.to_s.downcase\n return... | [
"0.6520394",
"0.6366538",
"0.6266593",
"0.62323165",
"0.61974835",
"0.60926694",
"0.60926694",
"0.60916203",
"0.6074853",
"0.60645974",
"0.60324836",
"0.5988682",
"0.59624296",
"0.59298015",
"0.586516",
"0.5808034",
"0.5728491",
"0.5712383",
"0.5707322",
"0.56599647",
"0.5648... | 0.7667094 | 0 |
grabs info about a particular host from PuppetDB | def query_pdb_host(certname, port)
require 'json'
require 'uri'
require 'net/http'
# TODO move to ssl
uri = URI("http://localhost:#{port}/pdb/query/v4/nodes/#{certname}")
@logger.debug("Running PDB query: #{uri}")
begin
data = JSON.parse(Net::HTTP.get(uri), :symbolize_names => true)
rescue Exception => e
err_msg = "#{e}\n" +
" Please make sure PuppetDB is running, this script is being run from\n" +
" the PuppetDB host, and the port is correct"
@logger.error err_msg
end
if data.keys.include? :error
err_msg = "Could not retrieve node data for #{certname}" +
" Server Said: #{data}"
@logger.error err_msg
end
@logger.debug("Received Response: #{data}")
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host_info\n @host_info\n end",
"def info_host(host)\n validate_list([[\"Host\", host, :presence]])\n options = {\"Host\" => host}\n\n connection = Connection.new\n connection.post(\"Domain/Host/Info\", options)\n end",
"def read_host_info\n json { execute_prlctl('server'... | [
"0.71584475",
"0.6903869",
"0.6807556",
"0.6788305",
"0.6779182",
"0.6728388",
"0.6660252",
"0.6635586",
"0.6595495",
"0.6592397",
"0.65791863",
"0.6530544",
"0.65098006",
"0.65021914",
"0.64845306",
"0.6412515",
"0.64074063",
"0.64074063",
"0.6381596",
"0.6335051",
"0.631482... | 0.66199803 | 8 |
grabs info about all hosts in PuppetDB | def query_pdb_hosts(port)
require 'json'
require 'uri'
require 'net/http'
# TODO move to ssl
uri = URI("http://localhost:#{port}/pdb/query/v4/nodes")
@logger.debug("Running PDB query: #{uri}")
begin
data = JSON.parse(Net::HTTP.get(uri), :symbolize_names => true)
rescue Exception => e
err_msg = "#{e}\n" +
" Please make sure PuppetDB is running, this script is being run from\n" +
" the PuppetDB host, and the port is correct"
@logger.error err_msg
end
@logger.debug("Received Response: #{data}")
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_puppetdb_hosts\n curl = setup_curl(\"#{@puppetdb_url}/v3/nodes\")\n curl.get\n servers_junk = JSON.parse(curl.body_str)\n servers_array = []\n servers_junk.each { |server| servers_array << server['name'] }\n @puppetdb_hosts = servers_array\n end",
"def hosts\n\t\tHost.find(:all)\n\tend... | [
"0.76432306",
"0.7234037",
"0.7156418",
"0.71213675",
"0.70130295",
"0.70130295",
"0.70130295",
"0.693774",
"0.68816054",
"0.6880734",
"0.6878883",
"0.67713785",
"0.6723216",
"0.66350704",
"0.6625218",
"0.6579706",
"0.6552434",
"0.6513989",
"0.6509409",
"0.64914787",
"0.64849... | 0.65868914 | 15 |
Update the passed hostlist with the values for the passed hosts. Updates with all data if hosts is empty | def query_files_hosts(hostlist, hosts)
report_dir = get_report_dir
existing_nodes = hostlist.map{|x| x[:certname]}
local_host_template = {
:deactivated=>false,
:latest_report_hash=>nil,
:facts_environment=>nil,
:cached_catalog_status=>"not_used",
:report_environment=>nil,
:latest_report_corrective_change=>nil,
:catalog_environment=>nil,
:facts_timestamp=>nil,
:latest_report_noop=>nil,
:expired=>false,
:latest_report_noop_pending=>nil,
:report_timestamp=>nil,
:certname=>nil,
:catalog_timestamp=>nil,
:latest_report_job_id=>nil,
:latest_report_status=>nil
}.freeze
local_host_reports = []
if File.directory?(report_dir)
@logger.debug("Processing Report Directory: #{report_dir}")
Dir.glob("#{report_dir}/*").each do |node_dir|
@logger.debug("Processing Node Directory: #{node_dir}")
latest_report = Dir.glob("#{node_dir}/*.yaml").sort.last
if latest_report
@logger.debug("Processing YAML Report: #{latest_report}")
begin
require 'puppet'
transaction_report = YAML.load_file(latest_report)
unless (hosts.empty? || hosts.include?(transaction_report.host))
@logger.debug("Skipping #{transaction_report.host} since it is not in the host list")
next
end
if existing_nodes.include?(transaction_report.host)
@logger.debug("Skipping #{transaction_report.host} since it already exists")
next
end
local_host_data = Marshal.load(Marshal.dump(local_host_template))
local_host_data[:latest_report_hash] = transaction_report.catalog_uuid
local_host_data[:facts_environment] = transaction_report.environment
local_host_data[:report_environment] = transaction_report.environment
local_host_data[:latest_report_corrective_change] = transaction_report.corrective_change
local_host_data[:catalog_environment] = transaction_report.environment
local_host_data[:facts_timestamp] = transaction_report.time.to_s
local_host_data[:latest_report_noop] = transaction_report.noop
local_host_data[:latest_report_noop_pending] = transaction_report.noop_pending
local_host_data[:report_timestamp] = transaction_report.time.to_s
local_host_data[:certname] = transaction_report.host
local_host_data[:catalog_timestamp] = transaction_report.time.to_s
local_host_data[:latest_report_job_id] = transaction_report.catalog_uuid
local_host_data[:latest_report_status] = transaction_report.status
hostlist << local_host_data
@logger.debug("Processed Host Report: #{local_host_data}")
rescue => e
@logger.warn "Error processing report at '#{latest_report}': #{e}"
end
else
@logger.debug "Could not find latest report in '#{node_dir}'"
end
end
else
@logger.debug "Could not find report directory at '#{report_dir}'"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_host(host, ip_list)\n validate_list([[\"Host\", host, :presence], [\"IP_List\", ip_list, :presence]])\n options = {\"Host\" => host, \"IP_List\" => ip_list}\n\n connection = Connection.new\n connection.post(\"Domain/Host/Update\", options)\n end",
"def hosts=(hosts)\n @host... | [
"0.7520346",
"0.6585109",
"0.65630496",
"0.6439962",
"0.6412815",
"0.6406071",
"0.63059604",
"0.62790745",
"0.62790745",
"0.6248175",
"0.62462497",
"0.6141535",
"0.60170156",
"0.5994991",
"0.59805655",
"0.5972963",
"0.597183",
"0.59278744",
"0.5853054",
"0.5848717",
"0.583442... | 0.5620037 | 33 |
take the PuppetDB scehema and transform it into useful info for us | def transform_hosts(hosts)
require 'time'
node_data = []
hosts.each do |host|
if host[:report_timestamp].nil?
# This can happen in weird cases. Mark as an expired node, so
# the expired logic doesn't try to do math on a nil timestamp.
last_checkin = nil
formatted_checkin = 'N/A'
host[:expired] = nil
else
last_checkin = Time.now - Time.parse(host[:report_timestamp])
formatted_checkin = sprintf("%#{@options.round_to}f",(last_checkin * @options.divisor).abs)
end
node_data << {
:last_checkin => last_checkin,
:expired => host[:expired].nil? ? false : host[:expired],
:certname => host[:certname],
:environment => host[:report_environment].nil? ? 'N/A' : host[:report_environment],
:status => host[:latest_report_status].nil? ? 'N/A' : host[:latest_report_status],
:formatted_checkin => formatted_checkin
}
end
unless @options.environments.empty?
node_data.delete_if {|node| not @options.environments.include? node[:environment] }
end
unless @options.statuses.empty?
node_data.delete_if {|node| not @options.statuses.include? node[:status] }
end
node_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema\n @_format.schema\n end",
"def schema(table, opts={})\n hero = execute(\"DESCRIBE #{table}\")\n hero.map do |h|\n [\n h[:col_name].strip.to_sym,\n { :db_type => h[:data_type].strip , :comment => h[:comment].strip }\n ]\n end\n e... | [
"0.5806624",
"0.5683235",
"0.56606895",
"0.5633703",
"0.55633426",
"0.55521137",
"0.5543703",
"0.54960537",
"0.54793173",
"0.53696424",
"0.5359551",
"0.5351858",
"0.53385216",
"0.530446",
"0.5254253",
"0.5247635",
"0.52411675",
"0.52299196",
"0.52043563",
"0.51771283",
"0.516... | 0.0 | -1 |
sort hosts list according to the option | def sort_hosts(hosts,sort_by)
case sort_by
when :certname
return hosts.sort{ |a,b| a[:certname] <=> b[:certname] }
when :time
return hosts.sort{ |a,b|
if a[:last_checkin].nil? and !b[:last_checkin].nil?
1
elsif !a[:last_checkin].nil? and b[:last_checkin].nil?
-1
else
a[:last_checkin] <=> b[:last_checkin]
end
}
when :status
return hosts.sort{ |a,b| a[:status].downcase <=> b[:status].downcase }
when :environment
return hosts.sort{ |a,b| a[:environment] <=> b[:environment] }
else
return hosts
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_host_grid\n assert_privileges(\"miq_request_edit\")\n return unless load_edit(\"prov_edit__#{params[:id]}\", \"show_list\")\n\n sort_grid('host', @edit[:wf].get_field(:placement_host_name, :environment)[:values])\n end",
"def sorted_ip(hosts_hash)\n hosts_hash.keys.sort_by { |ip|\n a,b,c,d... | [
"0.6581939",
"0.63798106",
"0.6134357",
"0.6128738",
"0.61221254",
"0.6107028",
"0.6080425",
"0.5969106",
"0.58336735",
"0.57799315",
"0.57559264",
"0.5731035",
"0.5712979",
"0.5697514",
"0.5691836",
"0.5663905",
"0.5662628",
"0.56309354",
"0.5595657",
"0.5592202",
"0.5579932... | 0.7173006 | 0 |
find max length of element and return it | def find_longest(sorted_data, key)
keys = sorted_data.map { |h| h[key].to_s }
return keys.max_by(&:length).length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findMax(a)\n\ta.length\nend",
"def max_length(attribute)\n return 0 if items.empty?\n items.map(&attribute.to_sym).max_by(&:length).size\n end",
"def max\n @max ||= map {|a| a[0].length}.max\n end",
"def length\n @length.kind_of?(Range) ? @length.max : @length\n end",
"def ... | [
"0.7791119",
"0.7575048",
"0.75554734",
"0.7484935",
"0.7452516",
"0.7399513",
"0.7360989",
"0.7326958",
"0.7322258",
"0.72244537",
"0.72239935",
"0.7193844",
"0.71816087",
"0.71717197",
"0.7136517",
"0.71068954",
"0.70877457",
"0.7082403",
"0.70776325",
"0.70618033",
"0.7040... | 0.66657096 | 70 |
Push a connection on the queue. | def push(connection)
synchronize do
@queue.push(connection)
@cond.signal
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(conn)\n # No need to cache if the connection has already been closed.\n return if closed?(conn)\n\n connections.synchronize do\n connections.push([Time.now + idle_timeout, conn])\n end\n end",
"def push_connection(conn_key, spec, th = nil)\n conns = tconf(th).connections\n n_... | [
"0.70210874",
"0.6863105",
"0.66766065",
"0.6586564",
"0.6550053",
"0.647847",
"0.6452492",
"0.64172006",
"0.63637966",
"0.6192346",
"0.6131038",
"0.61185247",
"0.61083037",
"0.6082668",
"0.60824645",
"0.6065117",
"0.605857",
"0.60523844",
"0.59896946",
"0.59708583",
"0.59624... | 0.77880883 | 0 |
Pop the next connection off the queue. | def shift
deadline = Time.now + @timeout
synchronize do
loop do
return @queue.shift unless @queue.empty?
wait = deadline - Time.now
raise Timeout::Error, "Waited for #{@timeout} seconds for connection but none was pushed." if wait <= 0
@cond.wait(wait)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop\n connections.synchronize do\n evict\n _, connection = connections.pop\n connection\n end\n end",
"def pop()\n res = @pop_queue.shift()\n return res\n end",
"def pop()\n @queue.shift\n end",
"def pop!\n @mutex.synchronize do\n loop do\n ... | [
"0.755293",
"0.7543232",
"0.7536304",
"0.7465208",
"0.74468035",
"0.7322853",
"0.73086166",
"0.71670985",
"0.7107164",
"0.7096955",
"0.7094762",
"0.7064289",
"0.705689",
"0.70327145",
"0.69294906",
"0.6911418",
"0.69001603",
"0.68991876",
"0.6886852",
"0.6872747",
"0.6844513"... | 0.6176637 | 68 |
Is the queue empty? | def empty?
@queue.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty()\n @queue.size == 0\n end",
"def is_empty()\n @queue.count { _1 } == 0\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.... | [
"0.9379387",
"0.9364612",
"0.93427914",
"0.93427914",
"0.93427914",
"0.93405193",
"0.9294838",
"0.92472124",
"0.9171745",
"0.9006615",
"0.8962932",
"0.8851832",
"0.87521917",
"0.86120766",
"0.8583436",
"0.8579887",
"0.8481455",
"0.8481455",
"0.8481455",
"0.84505105",
"0.84101... | 0.92711985 | 7 |
Get the current size of the queue. | def size
@queue.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n\n @queue.size\n end",
"def size\n @queue.size\n end",
"def queue_size\n _get(\"/system/queue-size\") { |json| json }\n end",
"def size\n @queue.size\n end",
"def size\n @queue.size\n end",
"def size\n @mutex.synchronize { @queue.size }\n end",
... | [
"0.8483858",
"0.8455337",
"0.8451002",
"0.8446962",
"0.83948755",
"0.8367717",
"0.80201346",
"0.7864384",
"0.7850798",
"0.78053844",
"0.7785047",
"0.77693117",
"0.7716137",
"0.77120304",
"0.76998174",
"0.76656735",
"0.7604601",
"0.757399",
"0.74067473",
"0.73887783",
"0.73851... | 0.8433791 | 4 |
GET /lists GET /lists.json | def index
@lists = current_user.lists.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lists\n response = rest(\"get\", \"lists\")\n\n return response[\"lists\"]\n end",
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def index\n @lists = current_user.lists\n #@lists = List.all\n render json: @lists\n end",
"def index\n @lists = L... | [
"0.80919707",
"0.7942851",
"0.78779286",
"0.7858385",
"0.7814817",
"0.77347493",
"0.7703373",
"0.7641295",
"0.76274574",
"0.74937147",
"0.7423371",
"0.7332808",
"0.72778344",
"0.7242392",
"0.7241362",
"0.72268915",
"0.7203747",
"0.72001815",
"0.71932775",
"0.7186917",
"0.7130... | 0.6679688 | 52 |
GET /lists/1 GET /lists/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def get_list(user, list)\n get(\"/#{user}/lists/#{list}.json\")\n end",
"def index\n @list_items = List.find(params[:list_id]).list_items\n\n render json: @list_items\n end",
"def show\n @list = current_project.lists.f... | [
"0.81000805",
"0.7621268",
"0.76165867",
"0.75238293",
"0.73434776",
"0.73050016",
"0.728771",
"0.7281486",
"0.72767174",
"0.7225843",
"0.71916556",
"0.71916556",
"0.71916556",
"0.71916556",
"0.71828145",
"0.7050341",
"0.69989306",
"0.696094",
"0.690982",
"0.6844573",
"0.6843... | 0.0 | -1 |
POST /lists POST /lists.json | def create
@list = current_user.lists.new(new_list_params)
respond_to do |format|
if @list.save
format.html { redirect_to my_list_path(@list), notice: 'List was successfully created.' }
format.json { render :show, status: :created, location: my_list_path(@list) }
else
format.html { render :new }
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(params={})\n @obj.post('create-list', @auth.merge(params))\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def create\n @list = List.create!(list_params)\n json_response(@list, :created)... | [
"0.7744856",
"0.7644541",
"0.76097417",
"0.74585795",
"0.72567004",
"0.71968704",
"0.7191225",
"0.7155085",
"0.7108538",
"0.70642173",
"0.7063542",
"0.7063542",
"0.7013641",
"0.69427305",
"0.69293773",
"0.68952435",
"0.68616366",
"0.6841231",
"0.67964596",
"0.679132",
"0.6779... | 0.7029331 | 12 |
PATCH/PUT /lists/1 PATCH/PUT /lists/1.json | def update
respond_to do |format|
if @list.update(existing_list_params)
format.html { redirect_to my_list_path(@list), notice: 'List was successfully updated.' }
format.json { render :show, status: :ok, location: my_list_path(@list) }
else
format.html { render :edit }
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n ... | [
"0.76281315",
"0.72378355",
"0.7139185",
"0.7117268",
"0.7117268",
"0.71083647",
"0.7101187",
"0.7068508",
"0.7049937",
"0.7049937",
"0.70404303",
"0.70156926",
"0.7011639",
"0.6980567",
"0.69750524",
"0.69516975",
"0.69339174",
"0.6919702",
"0.6919702",
"0.6919702",
"0.69197... | 0.7041945 | 10 |
DELETE /lists/1 DELETE /lists/1.json | def destroy
@list.destroy
respond_to do |format|
format.html { redirect_to my_lists_url, notice: 'List was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_list(list_id)\n rest(\"delete\", \"lists/#{list_id}\")\n\n return true\n end",
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def destroy\n @list = List.find(params[:id])\n @list.destroy\n\n respond_to do |format|\n format.html { redirect... | [
"0.7906252",
"0.7809346",
"0.7779898",
"0.77558565",
"0.77558565",
"0.77558565",
"0.7716591",
"0.7716591",
"0.7716591",
"0.7579166",
"0.7510371",
"0.7500726",
"0.7500726",
"0.7500726",
"0.7500726",
"0.7500726",
"0.7500726",
"0.7500726",
"0.7497565",
"0.74764705",
"0.74714524"... | 0.74648166 | 21 |
Use callbacks to share common setup or constraints between actions. | def set_list
@list = current_user.lists.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.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865... | 0.0 | -1 |
initialize a new fixture instance name the name of the current test to run TODO: 1. Set your device capabilities. 2. Set your Perfecto lab user, password and host. | def initialize(name = nil)
super(name) unless name.nil?
host = 'LABNAME.perfectomobile.com'
@user = 'Your UserName'
pass = 'Your PW'
# device capabilities:
capabilities = {
:platformName => 'Android',
:model => '',
:platformVersion => '',
:browserName => 'mobileOS',
:browserVersion => '',
:deviceName => '',
:user => @user,
:password => pass
}
# create a new driver instance
@driver = Selenium::WebDriver.for(:remote, :url => 'http://' + host + '/nexperience/perfectomobile/wd/hub', :desired_capabilities => capabilities)
# create new reportium client
create_reportium_client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\r\n puts 'starting a new test: ' + self.name\r\n cfT1 = CustomField.new(\"testField\", \"kuku\")\r\n cfT2 = CustomField.new(\"tester\", \"new_tester\")\r\n @reportiumClient.testStart(self.name, TestContext.new(TestContext::TestContextBuilder\r\n\t .... | [
"0.65191954",
"0.6358325",
"0.6358325",
"0.6183893",
"0.6068099",
"0.6045242",
"0.60291266",
"0.5987103",
"0.594738",
"0.59457403",
"0.59385556",
"0.5936135",
"0.5900184",
"0.5895851",
"0.5873116",
"0.5852402",
"0.5852402",
"0.58331805",
"0.5822116",
"0.58208686",
"0.58043283... | 0.54279715 | 90 |
initialize reportium client TODO: (optional) Define a project, job and context tags for one or more tests. | def create_reportium_client
cf1 = CustomField.new("test", "sample")
cf2 = CustomField.new("tester", @user)
perfectoExecutionContext = PerfectoExecutionContext.new(
PerfectoExecutionContext::PerfectoExecutionContextBuilder
.withProject(Project.new('Reporting SDK Ruby', '1')) # Optional
.withJob(Job.new('Ruby Job', 2).withBranch("branch-ruby")) # Optional
.withContextTags('Test tag1', 'Test tag2', 'Test tag3') # Optional
.withCustomFields(cf1, cf2) # Optional
.withWebDriver(@driver)
.build)
@reportiumClient = PerfectoReportiumClient.new(perfectoExecutionContext)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_reportium_client\n perfectoExecutionContext = PerfectoExecutionContext.new(\n PerfectoExecutionContext::PerfectoExecutionContextBuilder\n .withProject(Project.new('Reporting SDK Ruby', '1')) # Optional\n .withJob(Job.new('Ruby Job', 1)) # Optional\n .withContex... | [
"0.7231719",
"0.64077073",
"0.62666726",
"0.61997914",
"0.60334265",
"0.5982094",
"0.5860028",
"0.5849645",
"0.57432866",
"0.57388556",
"0.5738355",
"0.5736627",
"0.56130695",
"0.56057364",
"0.55935335",
"0.55742604",
"0.5567461",
"0.55624",
"0.55622685",
"0.5541658",
"0.5539... | 0.72391236 | 0 |
setup method setup method runs before each test and indicate a reporting. add here additional before test settings. | def setup
puts 'starting a new test: ' + self.name
cfT1 = CustomField.new("testField", "kuku")
cfT2 = CustomField.new("tester", "new_tester")
@reportiumClient.testStart(self.name, TestContext.new(TestContext::TestContextBuilder
.withCustomFields(cfT1, cfT2)
.withTestExecutionTags('TagYW1', 'TagYW2', 'unittest')
.build()))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\n\n # Save the Global variable's original settings so that they can be changed in this\n # test without affecting other test, so long as they are restored by teardown\n @@VERBOSE_ORIG = $VERBOSE\n @@DEBUG_ORIG = $DEBUG\n @@FAST_SPEED_ORIG = $FAST_SPEED\n @@HIDE_IE_ORIG = $HIDE_IE\n\n ... | [
"0.7665989",
"0.7602157",
"0.7579282",
"0.7579282",
"0.7579282",
"0.7579282",
"0.7579282",
"0.75046855",
"0.7496106",
"0.74456644",
"0.74456644",
"0.7437333",
"0.7412735",
"0.7412735",
"0.74116755",
"0.7382381",
"0.7377769",
"0.73633325",
"0.73255837",
"0.7320916",
"0.7318309... | 0.77399427 | 0 |
End test method This method run after each test. If the test succeeded create a successful test report, Otherwise create a failure test report. Closing the current session. | def teardown
if self.passed?
@reportiumClient.testStop(TestResultFactory.createSuccess)
else
@reportiumClient.testStop(TestResultFactory.createFailure(@exception.message, @exception))
end
puts '========================================================================================================================'
puts 'report url: ' + @reportiumClient.getReportUrl
puts '========================================================================================================================'
@driver.close
@driver.quit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_test(test_status)\n # Abstract\n end",
"def end_test(test_status)\n # Abstract\n end",
"def finish\n\t\t\twrite_log_to_file(@logfile)\n\t\t\twrite_xmlfile(@xmlfile)\n\t\t\tif @errcount > 0 or @warncount > 0 then\n\t\t\t\twrite_log_to_stdout\n\t\t\tend\n\t\t\tputs \"Test ... | [
"0.739899",
"0.739899",
"0.7244707",
"0.72273386",
"0.70306355",
"0.70227265",
"0.7008613",
"0.6897105",
"0.68895257",
"0.67292297",
"0.67292297",
"0.67292297",
"0.66707146",
"0.6659845",
"0.6529249",
"0.6512932",
"0.65051943",
"0.6410376",
"0.64084476",
"0.64046186",
"0.6404... | 0.7504587 | 0 |
admin only can generate this report | def is_admin
if current_user.user_type != 1001
render json: {data: "you must login as admin...!" , meta: {status: false} } , status: 401
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_accessible?\n report || is_admin\n end",
"def admin_only\n deny_access(\"Necesitas tener privilegios de administrador para entrar.\") unless signed_in_as_admin?\n end",
"def require_admin_permission\n redirect_to tables_path, notice: 'Necesita permisos de administrador para visu... | [
"0.76286274",
"0.7036026",
"0.7022285",
"0.6983291",
"0.69754213",
"0.69754213",
"0.69754213",
"0.6759987",
"0.6759987",
"0.67431056",
"0.67348856",
"0.660926",
"0.6602365",
"0.6595044",
"0.6590404",
"0.65825343",
"0.65761703",
"0.6562646",
"0.6561403",
"0.65384483",
"0.65029... | 0.0 | -1 |
Gracefully shut down the connection. | def disconnect!
@driver.close
ensure
close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shutdown_connection\n teardown_timers\n @conn.shutdown if @conn.respond_to? :shutdown\n @conn.terminate if @conn.respond_to? :terminate\n @conn = nil\n end",
"def shutdown\n @conn.shutdown\n end",
"def shutdown\n connection.write(\"shutdown... | [
"0.7844399",
"0.7694907",
"0.7457424",
"0.7377247",
"0.724101",
"0.7214354",
"0.70967233",
"0.70716923",
"0.7030799",
"0.7022823",
"0.6960099",
"0.69594145",
"0.6931504",
"0.69173324",
"0.6862759",
"0.6845816",
"0.68451434",
"0.6768765",
"0.67620444",
"0.6743782",
"0.6743712"... | 0.0 | -1 |
Convert CSV to HASH based on first field, input csv_name, return the hash | def prod_to_hash(csv_name)
prod_array = CSV.read(csv_name)
prod_array.each_with_index do |line, index|
next if line[0] == "Opportunity ID"
break if line[0] == nil
@current_opp_list[line[0]] = Opportunity.new(line[@prods_opp], line[@prods_prod], line[@prods_access], line[@prods_status], "unknown")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end",
"def grades_to_hash(csv)\n csv.map { |r| r.to_hash }\n ... | [
"0.71611786",
"0.6971985",
"0.68420637",
"0.67427945",
"0.6717925",
"0.6688303",
"0.64841235",
"0.64439845",
"0.6373775",
"0.6362473",
"0.63616276",
"0.6357385",
"0.6355328",
"0.6355328",
"0.63117266",
"0.6295038",
"0.62867814",
"0.6236435",
"0.6200539",
"0.61728257",
"0.6160... | 0.7175659 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.