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 |
|---|---|---|---|---|---|---|
Returns an array representing the collection | def to_a
out = []
each { |e| out << e }
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array\n self.allObjects\n end",
"def to_a\n data.all\n end",
"def to_a\n records\n end",
"def to_a\n array\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def array()\n\t\t@array\n\tend",
"def to_ary\n [ self ]\n end",
"def to_a\n [ self ]\... | [
"0.7706593",
"0.73551553",
"0.72961235",
"0.7270969",
"0.72309506",
"0.71518683",
"0.7123896",
"0.7114295",
"0.7095757",
"0.7094945",
"0.70840895",
"0.70293576",
"0.70184606",
"0.70032424",
"0.69986844",
"0.69861734",
"0.6937448",
"0.6901362",
"0.68832403",
"0.6868045",
"0.68... | 0.0 | -1 |
Selects elements of the collections for which the supplied block evaluates to true | def select
out = []
each { |e| out << e if yield(e) }
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_select(&block)\n result = []\n my_each do |elem|\n result << elem if block.call(elem) == true\n end\n result\n end",
"def my_select (collection)\n if block_given?\n i = 0 \n new_collection = []\n \n while i < collection.length \n if yield(collection[i]) \n new_collectio... | [
"0.7246745",
"0.6765134",
"0.66143274",
"0.66035026",
"0.6525846",
"0.65086067",
"0.64556146",
"0.644707",
"0.6445662",
"0.6419971",
"0.64080095",
"0.6379314",
"0.6353729",
"0.63172853",
"0.6257367",
"0.6254317",
"0.6206331",
"0.6157675",
"0.61500245",
"0.61357796",
"0.612649... | 0.56573033 | 66 |
Returns an array resulting of applying the provided block to all of the elements of the collection | def map
out = []
each { |e| out << yield(e) }
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map &block\n new_array = [] # create a new array where elements will go into\n self.each {|el| new_array << (yield el)} # for each true element in the block, shovel that element into new array\n new_array # return the new array\n end",... | [
"0.74901503",
"0.7004588",
"0.6987886",
"0.6923599",
"0.6923599",
"0.69075525",
"0.6864782",
"0.6863176",
"0.6860534",
"0.68258065",
"0.6795701",
"0.6795701",
"0.677912",
"0.677912",
"0.6762553",
"0.6757016",
"0.67248195",
"0.67248195",
"0.67219865",
"0.66801715",
"0.6634789"... | 0.61504334 | 62 |
Pretty print the object. | def inspect
Thread.current[:formatador] ||= Formatador.new
data = "#{Thread.current[:formatador].indentation}<#{self.class.name}"
Thread.current[:formatador].indent do
unless self.instance_variables.empty?
vars = self.instance_variables.clone
vars.delete(:@client)
vars.delete(:@page)
data << " "
data << vars.map { |v| "#{v}=#{instance_variable_get(v.to_s).inspect}" }.join(", ")
end
end
data << " >"
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty(object)\n PP.pp(object, out)\n end",
"def pretty_inspect\n self.inspect\n end",
"def pretty_generate\n JSON.pretty_generate( self.to_h )\n end",
"def to_pretty\n to_s(:prettyprint => true)\n end",
"def prettify(obj)\n # Most look best with pretty_inspec... | [
"0.8105958",
"0.757013",
"0.74980974",
"0.74724275",
"0.7352843",
"0.7132593",
"0.71210694",
"0.71154165",
"0.7037319",
"0.7037319",
"0.6985385",
"0.69094306",
"0.6865536",
"0.681257",
"0.6796154",
"0.6748886",
"0.6738691",
"0.67271125",
"0.6721937",
"0.671694",
"0.6706551",
... | 0.68172663 | 13 |
GET /shifts GET /shifts.json | def index
@shifts = current_user.shiftweeks.last.shifts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shifts = @group.shifts\n @shift = current_user.shifts.new(group: @group)\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: Shift.fullcalendar_format(@shifts) }\n end\n end",
"def index\n vehicle_id = params[:vehicle_id]\n shi... | [
"0.7483017",
"0.73043025",
"0.7193605",
"0.7193605",
"0.7174193",
"0.71686226",
"0.71061426",
"0.69135803",
"0.6910592",
"0.67606026",
"0.67566884",
"0.6754934",
"0.67326605",
"0.6729341",
"0.6724575",
"0.67129004",
"0.66887444",
"0.6649638",
"0.6606693",
"0.6526036",
"0.6473... | 0.6935681 | 7 |
POST /shifts POST /shifts.json | def create
@shift = Shift.new(shift_params)
@shift.shiftweek = current_user.shiftweeks.last
respond_to do |format|
if @shift.save
current_user.update(on_shift: true)
format.html { redirect_to '/', notice: 'Shift was successfully created.' }
format.json { render :show, status: :created, location: @shift }
else
format.html { redirect_to '/' }
format.json { render json: @shift.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @shift = current_user.shifts.new shift_params.merge(group: @group)\n\n respond_to do |format|\n if @shift.save\n format.html { redirect_to group_shifts_url }\n format.json { render :show, status: :created, location: @shift }\n else\n format.html { render \"groups/#... | [
"0.71749306",
"0.709679",
"0.7018566",
"0.69380456",
"0.68919057",
"0.68573415",
"0.68130326",
"0.68027",
"0.6766381",
"0.6732007",
"0.66540116",
"0.6652076",
"0.665134",
"0.6621391",
"0.6563689",
"0.6522205",
"0.6479981",
"0.64796627",
"0.64348567",
"0.63611346",
"0.6330738"... | 0.63429964 | 20 |
PATCH/PUT /shifts/1 PATCH/PUT /shifts/1.json | def update
respond_to do |format|
if @shift.update(shift_params)
current_user.update(on_shift: false)
format.html { redirect_to '/', notice: 'Shift was successfully updated.' }
format.json { render :back, status: :ok, location: @shift }
else
format.html { redirect_to '/' }
format.json { render json: @shift.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_shift(id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/labor/shifts/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\... | [
"0.6900254",
"0.68934673",
"0.6833035",
"0.68163496",
"0.673695",
"0.673695",
"0.673695",
"0.673695",
"0.67108685",
"0.6659256",
"0.6617701",
"0.6607989",
"0.6547553",
"0.652671",
"0.64989716",
"0.6455414",
"0.6450669",
"0.64498377",
"0.64498377",
"0.64488775",
"0.64305055",
... | 0.67330605 | 8 |
Use callbacks to share common setup or constraints between actions. | def set_shift
@shift = Shift.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 shift_params
params.require(:shift).permit(:clockout, :clockin, :user_id, :shiftweek_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
def local_name(code) locale = locales.find(:first, :conditions => ["code = ?", code]) ret = locale.name if locale unless ret a = code.split("_") locale = locales.find(:first, :conditions => ["code = ?", a[0]]) ret = locale.name if locale end ret || self.name end | def local_name(languages)
ret = nil
if languages
lrs = languages.split(",")
lrs.each do |lr|
code = lr.split(";")[0]
locale = locales.find(:first, :conditions => ["code = ?", code])
ret = locale.name if locale
break if ret
end
end
ret || self.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def language_name(code)\n if configatron.locales.include?(code)\n t(:locale_name, :locale => code)\n else\n (entry = ISO_639.find(code.to_s)) ? entry.english_name : code.to_s\n end\n end",
"def get_country_name country_code\n country = Country.find(\n :first,\n :conditions => [\"... | [
"0.8079961",
"0.7404493",
"0.72784275",
"0.7244222",
"0.71233714",
"0.7078381",
"0.70774436",
"0.7038752",
"0.70316786",
"0.6936886",
"0.6895156",
"0.6827973",
"0.6787594",
"0.6773657",
"0.6701873",
"0.6671239",
"0.66398084",
"0.66197234",
"0.66197234",
"0.66197234",
"0.65694... | 0.8160559 | 0 |
Composite icon on swably feature art to ensure the size of sharing image is large enough for Facebook and Google+ using. | def icon4share
icon_path = self.display_icon.original
icon4share_path = icon_path + "4share.jpg"
unless File.exist?('public'+icon4share_path)
back = Magick::Image.read('public/images/back4share.jpg').first
icon = Magick::Image.read('public'+icon_path).first
result = back.composite(icon, Magick::CenterGravity, Magick::OverCompositeOp)
result.write('public'+icon4share_path)
end
icon4share_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def facebook_icon\n image_tag('facebook.png', border: 0)\n end",
"def feed_icon(activity)\n img = case activity_type(activity)\n when \"StatusUpdate\"\n \"friend_guy.gif\"\n when \"BlogPost\"\n \"note.gif\"\n when \"Entry\"\n \"page_w... | [
"0.62067634",
"0.6160004",
"0.61410123",
"0.6062613",
"0.6033415",
"0.6029381",
"0.59504956",
"0.5928614",
"0.59283894",
"0.58771557",
"0.5833097",
"0.58071923",
"0.5804713",
"0.5804713",
"0.57766235",
"0.57532966",
"0.5724782",
"0.570729",
"0.5682643",
"0.5667662",
"0.565173... | 0.650341 | 0 |
def self.local_path2cloud_name(path) path.gsub "/", "_" end recover review from app cache in data lost case. | def save_review
return unless self.review
begin
r = JSON.parse self.review
c = Comment.new
c.id = r['id']
c.content = r['content']
c.user_id = r['user']['id']
c.app_id = r['app']['id']
c.created_at = Time.at r['created_at']
c.model = r['model']
c.sdk = r['sdk']
c.image = r['image']
c.image_size = r['image_size']
c.sns_status_id = r['sns_status_id']
c.sns_id = r['sns_id']
c.in_reply_to_id = r['in_reply_to_id']
c.save
rescue
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partialize_path(path)\n if path.basename.to_s !~ /\\A_/\n Pathname.new path.to_s.sub(/([^\\/]+)\\Z/, '_\\1')\n end\n end",
"def partialize_path(path)\n if path.basename.to_s !~ /\\A_/\n Pathname.new path.to_s.sub(/([^\\/]+)\\Z/, '_\\1')\n end\n end",
... | [
"0.66238093",
"0.66238093",
"0.6546818",
"0.6492371",
"0.6483553",
"0.6403809",
"0.62303466",
"0.6228294",
"0.61883634",
"0.6178716",
"0.61470485",
"0.6138147",
"0.60914314",
"0.6083602",
"0.6077453",
"0.6046541",
"0.60459745",
"0.6043166",
"0.6039179",
"0.60348636",
"0.60288... | 0.0 | -1 |
Specifying this as a relationship didn't work, but this does | def logged_actions
versions.actions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def child_relation; end",
"def model_relationships; end",
"def one_relationship(name)\n end",
"def relationship(rel_class)\n @relationship = rel_class\n self\n end",
"def relationship\n relationship? ? children[1] : nil\n end",
"def associated\n end",
"def... | [
"0.74406344",
"0.7022375",
"0.70081925",
"0.697077",
"0.68700445",
"0.68384933",
"0.6832302",
"0.68084985",
"0.67446357",
"0.67446357",
"0.67118716",
"0.66804755",
"0.66804755",
"0.66804755",
"0.6615546",
"0.6597552",
"0.65759444",
"0.6559243",
"0.6559243",
"0.6455946",
"0.64... | 0.0 | -1 |
Specifying this as a relationship didn't work, but this does | def logged_actors
audited_actions.actors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def child_relation; end",
"def model_relationships; end",
"def one_relationship(name)\n end",
"def relationship(rel_class)\n @relationship = rel_class\n self\n end",
"def relationship\n relationship? ? children[1] : nil\n end",
"def associated\n end",
"def... | [
"0.7440207",
"0.70220876",
"0.70065296",
"0.696946",
"0.6869179",
"0.68382686",
"0.6832051",
"0.6807302",
"0.6744295",
"0.6744295",
"0.67111915",
"0.6680363",
"0.6680363",
"0.6680363",
"0.6615108",
"0.65973663",
"0.6574907",
"0.6558486",
"0.6558486",
"0.6456285",
"0.64525867"... | 0.0 | -1 |
GET /estatutos/1 GET /estatutos/1.json | def show
@estatuto = Estatuto.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @estatuto }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @estacionamiento = Estacionamiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @estacionamiento }\n end\n end",
"def show\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n format.html # s... | [
"0.69767076",
"0.6962822",
"0.6920201",
"0.6806446",
"0.6806446",
"0.6806402",
"0.6805962",
"0.67659324",
"0.676023",
"0.6757082",
"0.675513",
"0.67520833",
"0.67332464",
"0.6717374",
"0.6703175",
"0.669889",
"0.6682108",
"0.66804874",
"0.66709614",
"0.66071796",
"0.6592907",... | 0.754069 | 0 |
GET /estatutos/new GET /estatutos/new.json | def new
@estatuto = Estatuto.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @estatuto }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def new\n @sitio_entrega = SitioEntrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sit... | [
"0.7597043",
"0.757201",
"0.7552062",
"0.75334525",
"0.7498371",
"0.7481699",
"0.74554425",
"0.7422936",
"0.74219775",
"0.73717326",
"0.73645395",
"0.7363856",
"0.7363586",
"0.7341012",
"0.7314143",
"0.73133177",
"0.73024803",
"0.7302244",
"0.72873145",
"0.7278463",
"0.727299... | 0.79674006 | 0 |
POST /estatutos POST /estatutos.json | def create
@estatuto = Estatuto.new(params[:estatuto])
respond_to do |format|
if @estatuto.save
format.html { redirect_to @estatuto, notice: 'Estatuto was successfully created.' }
format.json { render json: @estatuto, status: :created, location: @estatuto }
else
format.html { render action: "new" }
format.json { render json: @estatuto.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @estacionamiento = Estacionamiento.new(params[:estacionamiento])\n\n respond_to do |format|\n if @estacionamiento.save\n format.html { redirect_to @estacionamiento, notice: 'Estacionamiento was successfully created.' }\n format.json { render json: @estacionamiento, status: :cr... | [
"0.66505474",
"0.66217273",
"0.6617827",
"0.6479541",
"0.6472816",
"0.6438972",
"0.64218",
"0.6406493",
"0.6404681",
"0.6398836",
"0.6384329",
"0.637451",
"0.63595873",
"0.63531",
"0.6318648",
"0.6292783",
"0.628382",
"0.6268582",
"0.6252593",
"0.6249211",
"0.6226379",
"0.6... | 0.7489206 | 0 |
PUT /estatutos/1 PUT /estatutos/1.json | def update
@estatuto = Estatuto.find(params[:id])
respond_to do |format|
if @estatuto.update_attributes(params[:estatuto])
format.html { redirect_to @estatuto, notice: 'Estatuto was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @estatuto.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def put!\n request! :put\n end",
"def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio... | [
"0.68548477",
"0.6831075",
"0.6506548",
"0.644001",
"0.643336",
"0.6383621",
"0.63407284",
"0.632758",
"0.6323982",
"0.6315266",
"0.62723327",
"0.62688786",
"0.6253012",
"0.62328815",
"0.62319195",
"0.62169224",
"0.62169224",
"0.6215583",
"0.6202635",
"0.61979854",
"0.6193404... | 0.703577 | 0 |
DELETE /estatutos/1 DELETE /estatutos/1.json | def destroy
@estatuto = Estatuto.find(params[:id])
@estatuto.destroy
respond_to do |format|
format.html { redirect_to estatutos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @testis = Teste.find(params[:id])... | [
"0.7486492",
"0.7286602",
"0.7270542",
"0.72657233",
"0.7223275",
"0.7166789",
"0.71656734",
"0.714614",
"0.71403205",
"0.71331704",
"0.71111923",
"0.70819694",
"0.7081246",
"0.707841",
"0.7074904",
"0.70709145",
"0.70709145",
"0.70649904",
"0.7063858",
"0.70534843",
"0.70475... | 0.7671161 | 0 |
iterate through the array, checking to see if the item equals the integer in question if equal, return the index (i.e. the location) | def search_array (array, integer)
array.each_with_index do |item, index|
if item == integer
return index
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_array(array, integer)\r\n # Search array for given integer\r\n array.each_with_index do |item, index|\r\n\r\n if item.eql? integer\r\n p index\r\n elsif !item.eql? integer\r\n nil\r\n else puts \"nil\"\r\n end\r\n \r\n end\r\nend",
"def ind... | [
"0.7460041",
"0.7459741",
"0.7300232",
"0.7255595",
"0.7249903",
"0.7243182",
"0.72113013",
"0.7209536",
"0.72091776",
"0.71693665",
"0.71671754",
"0.7106354",
"0.7085832",
"0.7061208",
"0.70109284",
"0.70044076",
"0.69939584",
"0.69906276",
"0.6954249",
"0.6930842",
"0.69050... | 0.75039434 | 0 |
Release 2 : Sort an Array Define a method that takes an array of numbers Compare the 1st and 2nd items in the array : and if 1st < 2nd, leave asis otherwise switch them reverse the swap them Then move on to the 2nd and 3rd items in the array if 2nd < 3rd, leave asis otherwise switch them/ reverse/ swap Then move onto the 3rd and 4th... Once all items have been compared, perform a check If 1st < 2nd < 3rd < 4th.. (and so on) is true, you're done! Otherwise, must start the process again, starting at 1st and 2nd items. Repeat the process until 1st < 2nd < 3rd < 4th is true | def run_pass(input)
corrections_made = false
(input.length - 1).times do |index|
if input[index] > input[index + 1]
corrections_made = true
val_0 = input[index +1]
val_1 = input[index]
input[index] = val_0
input[index + 1] = val_1
end
end
return corrections_made
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_sort(arr)\nx = arr.length\nif x == 1\nelsif x == 2\n if arr[0] > arr[1]\n arr[0], arr[1] = arr[1], arr[0]\n end\nelse\n loop do\n modified = FALSE\n (x-2).times do |x|\n if (arr[x] < arr[x + 1]) && (arr[x] < arr[x + 2])\n if arr[x + 2] < arr[x + 1]\n arr[x], arr[x + 1], a... | [
"0.81465614",
"0.80743665",
"0.7904076",
"0.79003596",
"0.7882885",
"0.78714675",
"0.7867113",
"0.7867113",
"0.7850113",
"0.78495777",
"0.78395134",
"0.783152",
"0.7790129",
"0.7784555",
"0.7780977",
"0.7777321",
"0.7751583",
"0.77502203",
"0.77398884",
"0.7733041",
"0.773301... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_artist
@artist = Artist.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def artist_params
params.require(:artist).permit(:name, :age)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Add a method to the Bus class which returns how many passengers are on the bus. | def test_get_number_passengers
assert_equal(0, @bus1.number_passengers())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def how_many_on_bus\n return @passengers.length\n end",
"def passenger_count()\n return @passengers.size()\n end",
"def number_of_passengers\n @passengers.length\n end",
"def count_passing\n return self.passing_products.size\n end",
"def count_members\n @band.count\n end",
"def count\... | [
"0.75179327",
"0.68771493",
"0.6806386",
"0.63530254",
"0.63331294",
"0.6293696",
"0.6178259",
"0.6120967",
"0.61148727",
"0.61098015",
"0.61010927",
"0.60999817",
"0.60999817",
"0.60999817",
"0.60943997",
"0.60943997",
"0.6054099",
"0.6054099",
"0.6054099",
"0.60483444",
"0.... | 0.5932702 | 31 |
Add a method to the Bus class which takes in a Person and adds it to the array of passengers. The method could look something like bus.pick_up(passenger1) | def test_pick_up
@bus1.pick_up(@person)
assert_equal(1, @bus1.number_passengers())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_passenger(person_obj)\n @passengers.push(person_obj)\n end",
"def pick_up_passenger(passenger) #In Ruby, while calculations always return anyway, \"return\" stops the method at that line.\n @passengers.push(passenger)\n end",
"def add (p)\n @people << p \n end",
"def addPerson(perso... | [
"0.6213432",
"0.6159111",
"0.6068701",
"0.59974736",
"0.59564847",
"0.56647193",
"0.565887",
"0.56366193",
"0.56064045",
"0.5585211",
"0.5583129",
"0.55014277",
"0.54902726",
"0.54413867",
"0.53925186",
"0.5388107",
"0.5371684",
"0.53701574",
"0.5367952",
"0.5355263",
"0.5332... | 0.52605003 | 27 |
Add a method that drops off a passenger and removes them from the array. This could look like bus.drop_off(passenger2) | def test_drop_off
@bus1.pick_up(@person)
assert_equal(1, @bus1.number_passengers())
@bus1.drop_off(@person)
assert_equal(0, @bus1.number_passengers())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_drop_passenger\n @bus.add_passenger(\"Jamie\")\n @bus.add_passenger(\"Steph\")\n @bus.drop_passenger(\"Steph\")\n assert_equal([\"Jamie\"], @bus.passengers)\n end",
"def drop_off_passenger(passenger)\n @passengers.delete(passenger)\n end",
"def drop_off(passanger)\n for person in @pa... | [
"0.657948",
"0.64777493",
"0.6426495",
"0.63326484",
"0.6024719",
"0.5877645",
"0.58624536",
"0.5745094",
"0.5692676",
"0.56769454",
"0.5609823",
"0.5603676",
"0.56014806",
"0.5542358",
"0.5526095",
"0.55248564",
"0.5521211",
"0.5516649",
"0.5497865",
"0.5484116",
"0.54703194... | 0.5844322 | 7 |
Add an 'empty' method to remove all of the passengers this might be used when the bus reaches its destination, or if the bus breaks down. It should remove all of the passengers from the array. | def test_empty
@bus1.pick_up(@person)
assert_equal(1, @bus1.number_passengers())
@bus1.empty
assert_equal(0, @bus1.number_passengers())
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty\n @passengers = []\n end",
"def empty_bus()\n @passengers.clear()\n end",
"def clear()\n if @extend then\n @tiers.clear\n else\n @tiers.each do |tier|\n tier.clear\n end\n end\n \n @length = 0\n end",
... | [
"0.7889322",
"0.7438873",
"0.5869277",
"0.58542806",
"0.5849449",
"0.5845885",
"0.58400774",
"0.58051234",
"0.56204367",
"0.560614",
"0.5596287",
"0.5579491",
"0.555677",
"0.5556376",
"0.55287224",
"0.5515953",
"0.5511381",
"0.5506291",
"0.5503071",
"0.5477519",
"0.5475907",
... | 0.0 | -1 |
Execute a PowerShell command and process the results | def execute(path, options={})
if path.is_a?(Symbol)
path = "#{path}.ps1"
end
r = execute_powershell(path, options)
# We only want unix-style line endings within Vagrant
r.stdout.gsub!("\r\n", "\n")
r.stderr.gsub!("\r\n", "\n")
error_match = ERROR_REGEXP.match(r.stdout)
output_match = OUTPUT_REGEXP.match(r.stdout)
if error_match
data = JSON.parse(error_match[1])
# We have some error data.
raise Errors::PowerShellError,
script: path,
stderr: data["error"]
end
if r.exit_code != 0
raise Errors::PowerShellError,
script: path,
stderr: r.stderr
end
# Nothing
return nil if !output_match
return JSON.parse(output_match[1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shell_execute(command)\n require 'open3'\n stdout, stderr, status = Open3.capture3(command.chomp)\n if status.success? && status.exitstatus.zero?\n stdout\n else\n msg = \"Shell command failed: [#{command}] caused by <STDERR = #{stderr}>\"\n msg << \" STDOUT = #{stdout}... | [
"0.62509155",
"0.62290156",
"0.62074196",
"0.6192919",
"0.6160704",
"0.61489564",
"0.61341894",
"0.61241025",
"0.609331",
"0.6086596",
"0.6079164",
"0.6020274",
"0.6015407",
"0.5964978",
"0.59486675",
"0.594841",
"0.5944762",
"0.59407324",
"0.5914471",
"0.5911512",
"0.5902807... | 0.63414305 | 0 |
Fetch current state of the VM | def get_current_state
execute(:get_vm_status, VmId: vm_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(vm_name)\n `VBoxManage showvminfo #{vm_name}` =~ /^State:\\s+(.*)$/ ? $1 : 'unknown'\n end",
"def read_state\n output = execute(\"showvminfo\", @uuid, \"--machinereadable\")\n if output =~ /^name=\"<inaccessible>\"$/\n return :inaccessible\n elsif output =~ /^V... | [
"0.7447932",
"0.7399979",
"0.7357939",
"0.7230891",
"0.72223055",
"0.72095054",
"0.7180311",
"0.69485277",
"0.69374293",
"0.6894436",
"0.6890631",
"0.67852026",
"0.67842954",
"0.6783073",
"0.67756027",
"0.6775433",
"0.6731047",
"0.66799855",
"0.66762114",
"0.66193855",
"0.659... | 0.82510966 | 0 |
Export the VM to the given path | def export(path)
execute(:export_vm, VmId: vm_id, Path: path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(path)\n end",
"def export(path)\n # TODO: Progress\n execute(\"export\", @uuid, \"--output\", path.to_s)\n end",
"def export path\n File.write path, to_zonefile\n end",
"def export\n\t\t\t\tFile.open(File.join(@env[\"export.temp_dir\"], 'Vagrantfile'), \"w... | [
"0.7151986",
"0.69171536",
"0.6831158",
"0.65407217",
"0.59697133",
"0.59588146",
"0.5933791",
"0.5897932",
"0.58527774",
"0.58527774",
"0.5840277",
"0.5840277",
"0.5763831",
"0.57044816",
"0.567178",
"0.5662741",
"0.55983835",
"0.559636",
"0.55530554",
"0.55303967",
"0.55303... | 0.85489357 | 0 |
Get the IP address of the VM | def read_guest_ip
execute(:get_network_config, VmId: vm_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip\n unless @vm\n warn 'No Vm assigned to locate IP'\n return\n end\n @ip ||= detect_ip\n end",
"def ip_address\n # Does not work for now as the vmx path is not escape correctly by fission 0.4.0\n #return raw.network_info.data.first['ip_address']\n r... | [
"0.8412569",
"0.8265822",
"0.7990585",
"0.78766835",
"0.78455216",
"0.7789672",
"0.7758319",
"0.77529293",
"0.7733979",
"0.7656122",
"0.7586869",
"0.75653195",
"0.75412935",
"0.75356597",
"0.75255126",
"0.75142634",
"0.75068283",
"0.75056213",
"0.7478455",
"0.74417293",
"0.74... | 0.79100686 | 3 |
Get the MAC address of the VM | def read_mac_address
execute(:get_network_mac, VmId: vm_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_address\n mac = nil\n\n ovf.elements.each(\"//vbox:Machine/Hardware//Adapter\") do |ele|\n if ele.attributes['enabled'] == 'true'\n mac = ele.attributes['MACAddress']\n break\n end\n end\n\n if mac\n return mac\n else\n ... | [
"0.80916923",
"0.8015968",
"0.797149",
"0.79467916",
"0.7929063",
"0.7844069",
"0.7786303",
"0.77637106",
"0.7604474",
"0.75092745",
"0.7448009",
"0.7411363",
"0.7402698",
"0.73826",
"0.7348189",
"0.73369557",
"0.73369557",
"0.7312341",
"0.7274218",
"0.72304547",
"0.7152746",... | 0.8365462 | 0 |
Resume the VM from suspension | def resume
execute(:resume_vm, VmId: vm_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resume\n @suspended = false\n end",
"def resume\n @vm.resume\n end",
"def resume\n execute_prlctl('resume', @uuid)\n end",
"def resume\n end",
"def resume\n end",
"def resume\n @halt = false\n end",
"def resume; end",
"def resume; end",
"def s... | [
"0.84279376",
"0.8043573",
"0.7543655",
"0.7404897",
"0.7404897",
"0.73917675",
"0.7309643",
"0.7309643",
"0.72828656",
"0.7264805",
"0.723229",
"0.7181568",
"0.70741135",
"0.70734364",
"0.69639534",
"0.6955613",
"0.69517565",
"0.6934152",
"0.69122285",
"0.69047517",
"0.68764... | 0.7798112 | 2 |
Import a new VM | def import(options)
execute(:import_vm, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import\n export_from_veewee\n box_file = work_dir.join(\"#{IMAGE_NAME}.box\")\n log.info \"Importing #{veewee_provider} image into Vagrant\"\n system \"vagrant box add 'autoyast' #{box_file} --force\"\n end",
"def import_packer_fusion_vm(options)\n (exists,images_dir) = check_packer_v... | [
"0.68209094",
"0.63034195",
"0.62877715",
"0.6282834",
"0.62258863",
"0.61832505",
"0.6181317",
"0.60325366",
"0.58864427",
"0.5842479",
"0.5808566",
"0.58009505",
"0.5796897",
"0.57943887",
"0.5794302",
"0.57912964",
"0.57912964",
"0.57912964",
"0.57912964",
"0.5755164",
"0.... | 0.7937678 | 0 |
Set the VLAN ID | def net_set_vlan(vlan_id)
execute(:set_network_vlan, VmId: vm_id, VlanId: vlan_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_vlan\n @vlan = Vlan.find(params[:id])\n end",
"def vlanid=(value)\n Puppet.debug \"Updating vlan Id associated to the specified portgroup.\"\n begin\n @networksystem=host.configManager.networkSystem\n portg=find_portgroup\n if (find_vswitch == false)\n raise Puppet::Error,... | [
"0.7843297",
"0.7546004",
"0.7446111",
"0.7446111",
"0.72417414",
"0.6989259",
"0.69435185",
"0.69435185",
"0.6719848",
"0.65452623",
"0.63605237",
"0.6323568",
"0.6323568",
"0.6284508",
"0.62242395",
"0.6129134",
"0.596922",
"0.5898261",
"0.5861333",
"0.58459383",
"0.5826994... | 0.7547431 | 1 |
Set the VM adapter MAC address | def net_set_mac(mac_addr)
execute(:set_network_mac, VmId: vm_id, Mac: mac_addr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_mac_address(mac)\n execute(\"modifyvm\", @uuid, \"--macaddress1\", mac)\n end",
"def set_mac_address(mac)\n end",
"def change_vbox_vm_mac(client_name,client_mac)\n message = \"Setting:\\tVirtualBox VM \"+client_name+\" MAC address to \"+client_mac\n if client_mac.match(/:/)\n cl... | [
"0.78571326",
"0.74459594",
"0.7020182",
"0.6981134",
"0.6856513",
"0.653054",
"0.63699424",
"0.6348041",
"0.6328344",
"0.62642807",
"0.6254569",
"0.6254569",
"0.623931",
"0.6221135",
"0.6215259",
"0.6215259",
"0.6175008",
"0.6095843",
"0.60651124",
"0.6048034",
"0.6048034",
... | 0.7446358 | 1 |
Create a new snapshot with the given name | def create_snapshot(snapshot_name)
execute(:create_snapshot, VmId: vm_id, SnapName: snapshot_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_snapshot(name)\n Fission::Action::Snapshot::Creator.new(self).create_snapshot(name)\n end",
"def create_snapshot(name)\n unless exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n running_response = running?\n return running_response u... | [
"0.86874354",
"0.7963352",
"0.78041565",
"0.7722622",
"0.76626754",
"0.75929207",
"0.7172898",
"0.7153735",
"0.6974902",
"0.69443744",
"0.6700415",
"0.6653902",
"0.6573599",
"0.6488946",
"0.64068174",
"0.6382022",
"0.63542634",
"0.6286373",
"0.62736183",
"0.62651336",
"0.6196... | 0.84266865 | 1 |
Restore the given snapshot | def restore_snapshot(snapshot_name)
execute(:restore_snapshot, VmId: vm_id, SnapName: snapshot_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore(body = {}, params = {})\n response = client.post \"/_snapshot/{repository}/{snapshot}/_restore\", update_params(params, body: body, action: \"snapshot.restore\", rest_api: \"snapshot.restore\")\n response.body\n end",
"def restore\n RESTORE\n end",
"def restore_snapshot(v... | [
"0.7772059",
"0.76738685",
"0.74655235",
"0.7432065",
"0.7350576",
"0.73297364",
"0.70708275",
"0.7044291",
"0.7031837",
"0.69781095",
"0.6973707",
"0.69204783",
"0.69020444",
"0.68924814",
"0.6855677",
"0.6788491",
"0.6736095",
"0.66749537",
"0.6642825",
"0.6634512",
"0.6633... | 0.8030771 | 0 |
Get list of current snapshots | def list_snapshots
snaps = execute(:list_snapshots, VmID: vm_id)
snaps.map { |s| s['Name'] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snapshots\n Fission::Action::Snapshot::Lister.new(self).snapshots\n end",
"def available_snapshots\n snapshot_info = `#{config[:path]} --json snapshots`\n JSON.parse(snapshot_info, { symbolize_names: true })\n end",
"def snapshots\n raise Fission::Error,\"VM #{@name} does not exist\" un... | [
"0.81450117",
"0.81024325",
"0.78101903",
"0.77493703",
"0.76898384",
"0.7672842",
"0.7658884",
"0.7517738",
"0.7490369",
"0.7381001",
"0.7308693",
"0.728614",
"0.72170705",
"0.7200573",
"0.7155368",
"0.71461254",
"0.7141946",
"0.6871219",
"0.67401785",
"0.6720873",
"0.663078... | 0.7987818 | 2 |
Delete snapshot with the given name | def delete_snapshot(snapshot_name)
execute(:delete_snapshot, VmID: vm_id, SnapName: snapshot_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_snapshot(name)\n Fission::Action::Snapshot::Deleter.new(self).delete_snapshot(name)\n end",
"def delete_snapshot(name)\n result = get_snapshot(name)\n response = @client.rest_delete(result['uri'], { 'If-Match' => result['eTag'] }, @api_version)\n @client.response_handler(r... | [
"0.9042199",
"0.8846741",
"0.82981235",
"0.77164304",
"0.7712967",
"0.76757604",
"0.7520961",
"0.735899",
"0.7328863",
"0.7235009",
"0.7212011",
"0.7078023",
"0.70325035",
"0.70185864",
"0.69793016",
"0.69673896",
"0.68556",
"0.68385124",
"0.6815459",
"0.6811317",
"0.67006946... | 0.8775238 | 2 |
Enable or disable VM integration services | def set_vm_integration_services(config)
config.each_pair do |srv_name, srv_enable|
args = {VMID: vm_id, Name: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name).to_s}
args[:Enable] = true if srv_enable
execute(:set_vm_integration_services, args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable\n @service.disabled = false\n end",
"def EnableDisable\n # Workaround for bug #61055:\n Builtins.y2milestone(\"Enabling service %1\", \"network\")\n cmd = \"cd /; /sbin/insserv -d /etc/init.d/network\"\n SCR.Execute(path(\".target.bash\"), cmd)\n\n nil\n end",
"de... | [
"0.7126952",
"0.68970066",
"0.6714214",
"0.65474725",
"0.6353881",
"0.63487756",
"0.6269334",
"0.62119347",
"0.6114682",
"0.60848486",
"0.60451126",
"0.6003971",
"0.59252715",
"0.5882555",
"0.5857993",
"0.5843681",
"0.580965",
"0.57908326",
"0.578729",
"0.5771576",
"0.5758237... | 0.7495388 | 0 |
Set the name of the VM | def set_name(vmname)
execute(:set_name, VMID: vm_id, VMName: vmname)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(name)\n @name = name\n end",
"def set_name(uuid, new_name)\n execute_prlctl('set', uuid, '--name', new_name)\n end",
"def define_machine_name(config, name)\n config.vm.provider \"virtualbox\" do |v|\n v.name = name\n end\nend",
"def set_name=(name)\n @name = name\n e... | [
"0.73663783",
"0.73421013",
"0.7314145",
"0.7059005",
"0.7034664",
"0.7034664",
"0.6970189",
"0.69388044",
"0.69379526",
"0.6935177",
"0.69250095",
"0.691099",
"0.69103956",
"0.6887396",
"0.6852156",
"0.68394136",
"0.6828535",
"0.6807583",
"0.6807583",
"0.6807583",
"0.6807583... | 0.8418402 | 0 |
can render any page, but a redirect will result in a redirect loop | def unauthorized_request user:current_user,filter:nil
puts "\n\nNo filter matches the given http method, controller, or controller method, rerouting..." if filter.blank?
puts "\n\nUser #{user.email} is not authorized to #{filter.http_method.upcase}::>#{filter.controller || 'all'}.#{filter.action_name || 'all'}, rerouting...\n\n" unless filter.blank?
render json: "Unauthorized Request"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to(url)\n self.res.status = 302\n #how would I know about location\n self.res.header[\"location\"] = url\n session.store_session(self.res)\n\n #self.res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, url)\n if already_rendered?\n raise \"Can't render/redirect twice\"\n ... | [
"0.74655896",
"0.7422501",
"0.7353421",
"0.73164463",
"0.72623813",
"0.7181438",
"0.71436054",
"0.7109625",
"0.7045785",
"0.7034472",
"0.70111465",
"0.7006541",
"0.697035",
"0.697035",
"0.69698024",
"0.69698024",
"0.69271857",
"0.6822865",
"0.6796399",
"0.6796399",
"0.6786319... | 0.0 | -1 |
returns all images array and makes/model hash for dropdown | def get_images_data
{ payload: { 'makes' => makes_dropdown, 'images' => images_array('none').compact}, success: true}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_image\n compute.images.map { |i| [i.name, i.id] }\n end",
"def images\n []\n end",
"def images; end",
"def get_images\n {}\n end",
"def imgs obj\n Image.find(obj.image_ids)\n end",
"def images_select_album_create_render\n @images_ids = []\n images_ids = params[:im... | [
"0.7242252",
"0.7044299",
"0.6912189",
"0.6816897",
"0.6811696",
"0.67475265",
"0.67288786",
"0.66552913",
"0.66460675",
"0.65771693",
"0.6562749",
"0.65457124",
"0.65413857",
"0.65296847",
"0.6519847",
"0.64633065",
"0.64274555",
"0.6414788",
"0.64115816",
"0.64066106",
"0.6... | 0.73987156 | 0 |
returns all images array with 'id' model or make and makes/model hash for dropdown | def get_hash(key, id)
{ payload: { 'makes' => makes_dropdown, 'images' => images_array(key, id).compact.take(10), 'selected_key' => id}, success: true}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_image\n compute.images.map { |i| [i.name, i.id] }\n end",
"def imgs\n @id = params[:id]\n @all_photos = ProductPhoto.where(product_id: params[:id])\n @photo = ProductPhoto.new\n \n end",
"def by_make_model(make, model)\n by_make(make).select ... | [
"0.7020305",
"0.69182706",
"0.6898276",
"0.68436813",
"0.6830602",
"0.66787827",
"0.65355444",
"0.6494969",
"0.6489766",
"0.64153725",
"0.6411458",
"0.62935174",
"0.6175269",
"0.6165873",
"0.61519843",
"0.6147921",
"0.6140572",
"0.6140572",
"0.6129854",
"0.60818785",
"0.60741... | 0.5848741 | 45 |
Return the source image of the server's boot disk | def image_name
boot_disk = disks.first
unless boot_disk.is_a?(Disk)
source = boot_disk[:source]
match = source.match(%r{/zones/(.*)/disks/(.*)$})
boot_disk = service.disks.get(match[2], match[1])
end
boot_disk.source_image.nil? ? nil : boot_disk.source_image
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source(disk)\n \"#{disk.sysds_path}/#{disk.vm_id}/disk.#{disk.id}\"\n end",
"def disk_image_url\n \"https://matthewtodd.org/downloads/#{disk_image_path}\"\n end",
"def default_image\n \"/var/lib/libvirt/images/kitchen-#{instance.platform.name}\"\n end",
"def get_iso\n @... | [
"0.68746036",
"0.67687947",
"0.6446293",
"0.6272478",
"0.62501246",
"0.591136",
"0.58907115",
"0.58759874",
"0.58169186",
"0.5809142",
"0.57886004",
"0.5772081",
"0.5744354",
"0.5737555",
"0.572006",
"0.5658216",
"0.5652065",
"0.56443626",
"0.56339145",
"0.56326437",
"0.56268... | 0.73655856 | 0 |
Helper method that returns first public ip address needed for Fog::Compute::Server.ssh default behavior. | def public_ip_address
public_ip_addresses.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_ip_of(server)\n server[:cloud][:public_ips].first rescue server[:ipaddress]\n end",
"def public_ip\n get('tools/public_ip').body['ipv4'] || get('tools/public_ip').body['ipv6']\n end",
"def get_public_ip\n case host_hash[:hypervisor]\n when /^(ec2|openstack)$/\n if s... | [
"0.83425003",
"0.79262257",
"0.7815771",
"0.776747",
"0.7755307",
"0.7680393",
"0.7517886",
"0.7440195",
"0.73191607",
"0.7307165",
"0.7279659",
"0.718978",
"0.7178923",
"0.7160814",
"0.70594925",
"0.7052261",
"0.7047636",
"0.6936407",
"0.68776137",
"0.6849938",
"0.67753416",... | 0.80463034 | 1 |
Helper method that returns all of server's public ip addresses. | def public_ip_addresses
addresses = []
if network_interfaces.respond_to? :flat_map
addresses = network_interfaces.flat_map do |nic|
if nic[:access_configs].respond_to? :each
nic[:access_configs].select { |config| config[:name] == "External NAT" }
.map { |config| config[:nat_ip] }
else
[]
end
end
end
addresses
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_ips\n hwaddr = self.hwaddr\n Hash[\n Meta.connection do\n Meta.interface(hwaddr, 'ipv4-associations/', not_found: '', cache: false).lines.map do |public_ip|\n public_ip.strip!\n unless private_ip = Meta.interface(hwaddr, \"ipv4-associations/#{p... | [
"0.7848865",
"0.78258634",
"0.7724755",
"0.77116084",
"0.76682705",
"0.7582707",
"0.75668716",
"0.75644064",
"0.7531535",
"0.75118756",
"0.739088",
"0.732214",
"0.73033404",
"0.7178148",
"0.7164824",
"0.7084348",
"0.70724046",
"0.6985393",
"0.6972744",
"0.69111717",
"0.682907... | 0.8069913 | 0 |
Helper method that returns the first private ip address of the instance. | def private_ip_address
private_ip_addresses.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_private_ip\n ip_addresses = interface_addresses\n ip_addresses.each do |ip|\n if ip.start_with?(\"192\") || ip.start_with?(\"10\")\n return ip\n end\n end\n return nil\n end",
"def private_ip_of(server)\n server[:cloud][:private_ips].fir... | [
"0.7887134",
"0.7815549",
"0.77611464",
"0.763318",
"0.763318",
"0.7467506",
"0.7223801",
"0.71896666",
"0.7099567",
"0.69274664",
"0.68968207",
"0.6757325",
"0.6754257",
"0.6751626",
"0.6749855",
"0.67410684",
"0.67160153",
"0.6715535",
"0.6706467",
"0.67053235",
"0.66850626... | 0.87811846 | 0 |
Helper method that returns all of server's private ip addresses. | def private_ip_addresses
addresses = []
if network_interfaces.respond_to? :map
addresses = network_interfaces.map { |nic| nic[:network_ip] }
end
addresses
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_ipaddresses\n # Create an array to hold the addresses\n addresses = []\n\n # Iterate around the filter that has been populated\n entries.each do |entry|\n entry.ip_configurations.each do |ip_config|\n addresses << ip_config['private_ipaddress']\n end\n end\n\n # retur... | [
"0.8071405",
"0.774375",
"0.76128775",
"0.7511914",
"0.74927205",
"0.7419451",
"0.7408385",
"0.7215236",
"0.71716064",
"0.71575403",
"0.7142402",
"0.7120124",
"0.70674884",
"0.69986856",
"0.69889253",
"0.69889253",
"0.6960726",
"0.6949283",
"0.69180506",
"0.68844974",
"0.6857... | 0.8520257 | 0 |
Helper method that returns all of server's ip addresses, both private and public. | def addresses
private_ip_addresses + public_ip_addresses
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_ip_addresses\n addresses = []\n if network_interfaces.respond_to? :map\n addresses = network_interfaces.map { |nic| nic[:network_ip] }\n end\n addresses\n end",
"def all_ips_for(vm)\n vm.guest.net.map(&:ipAddress).flatten\n end",
"def pu... | [
"0.81917745",
"0.78943473",
"0.7785122",
"0.7753538",
"0.7691277",
"0.7492112",
"0.7460445",
"0.74323195",
"0.74098563",
"0.7366769",
"0.7346977",
"0.73384446",
"0.72720504",
"0.7220392",
"0.69858825",
"0.6970386",
"0.6957681",
"0.6943837",
"0.6937503",
"0.69147134",
"0.68509... | 0.78331405 | 2 |
Attach a disk to a running server | def attach_disk(disk, async = true, attached_disk_options = {})
requires :identity, :zone
if disk.is_a? Disk
disk_obj = disk.get_attached_disk
elsif disk.is_a? String
disk_obj = service.disks.attached_disk_obj(disk, attached_disk_options)
end
data = service.attach_disk(identity, zone_name, disk_obj)
operation = Fog::Compute::Google::Operations
.new(:service => service)
.get(data.name, data.zone)
operation.wait_for { ready? } unless async
reload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attach_disk(server_id, disk_id)\n with_thread_name(\"attach_disk(#{server_id}, #{disk_id})\") do\n server = @openstack.with_openstack { @openstack.compute.servers.get(server_id) }\n cloud_error(\"Server `#{server_id}' not found\") unless server\n\n volume = @openstack.with_openstack {... | [
"0.78368175",
"0.75133723",
"0.72026294",
"0.71808356",
"0.7178855",
"0.71096826",
"0.71048605",
"0.7064619",
"0.6931316",
"0.6895075",
"0.6843017",
"0.67387307",
"0.6718862",
"0.67102873",
"0.6707911",
"0.66656333",
"0.6585095",
"0.64605063",
"0.645109",
"0.6446589",
"0.6406... | 0.6598766 | 16 |
Detach disk from a running instance | def detach_disk(device_name, async = true)
requires :identity, :zone
data = service.detach_disk(identity, zone, device_name)
operation = Fog::Compute::Google::Operations
.new(:service => service)
.get(data.name, data.zone)
operation.wait_for { ready? } unless async
reload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detach\n begin\n run_baby_run 'hdiutil', ['detach', '-force', self.dev_node], :err => '/dev/null'\n rescue Exception => ex\n debug \"The disk image at #{@dev_node} could not be detached: #{ex}\"\n end\n end",
"def detach_disk(instance_id, disk_id)\n with_thread_name(\"det... | [
"0.7952129",
"0.77610415",
"0.7716118",
"0.76664966",
"0.7533177",
"0.7524198",
"0.73068625",
"0.7080213",
"0.69443136",
"0.6943148",
"0.68881047",
"0.6799472",
"0.675335",
"0.6678374",
"0.6644898",
"0.66214323",
"0.6587923",
"0.65425766",
"0.65240127",
"0.65082806",
"0.64759... | 0.70608854 | 8 |
Returns metadata items as a Hash. | def metadata_as_h
if metadata.nil? || metadata[:items].nil? || metadata[:items].empty?
return {}
end
Hash[metadata[:items].map { |item| [item[:key], item[:value]] }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items_hash()\n return @items\n end",
"def to_h\n Hash[items]\n end",
"def metadata\n hash.inject([]){ |list, data| list << MetaData.new(data[0], data[1][0]) }\n end",
"def generate_metadata\n data = Hash.new\n data['id'] = self.id\n data['title'] = self.title\n ... | [
"0.7388671",
"0.7280324",
"0.71123",
"0.6934921",
"0.68342334",
"0.67846745",
"0.6767053",
"0.674275",
"0.6707027",
"0.66956025",
"0.66345817",
"0.66297656",
"0.6625239",
"0.65767866",
"0.6576522",
"0.6499068",
"0.6475824",
"0.6472245",
"0.6472245",
"0.6467045",
"0.6415609",
... | 0.82318527 | 0 |
Check if instance is provisioning. On staging vs. provisioning difference: | def provisioning?
status == "PROVISIONING"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provision?\n true\n end",
"def provisioned?\n self.reload\n if @provisioning_state == 'AVAILABLE'\n true\n else\n false\n end\n end",
"def staging?\n status == \"STAGING\"\n end",
"def provisioning_state\n properties.provisioningState\... | [
"0.72543347",
"0.71659523",
"0.6808994",
"0.67498535",
"0.67456424",
"0.67064136",
"0.6703377",
"0.6613877",
"0.6609482",
"0.65687126",
"0.6419947",
"0.61135286",
"0.6076491",
"0.60552466",
"0.6019922",
"0.5993435",
"0.592741",
"0.5906032",
"0.59045416",
"0.59043473",
"0.5886... | 0.81178933 | 0 |
Check if instance is staging. On staging vs. provisioning difference: | def staging?
status == "STAGING"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def staging?\n self.environment == ENV_STAGE\n end",
"def staging?\n @staging_index != nil\n end",
"def staging\n if Rails.env.staging?\n head :ok\n else\n head :internal_server_error\n end\n end",
"def production?\n rails_env == \"production\" || rails_env == \"staging\"... | [
"0.8224632",
"0.75972587",
"0.69880086",
"0.64868623",
"0.6344465",
"0.62070817",
"0.6112116",
"0.60853237",
"0.6049195",
"0.6034796",
"0.6009185",
"0.599701",
"0.5990317",
"0.59675825",
"0.59556127",
"0.5930414",
"0.59221655",
"0.59183395",
"0.5898553",
"0.58752704",
"0.5842... | 0.84299517 | 0 |
Check if instance is stopped. | def stopped?
status == "TERMINATED"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopped?\n @stopped\n end",
"def stopped?\n @stopped\n end",
"def stopped?\n @stopped\n end",
"def stopped?\n @state == :stopped\n end",
"def stopped?\n self.state.name == \"stopped\"\n end",
"def stopped?\n\t\treturn ! self.running?\n\tend"... | [
"0.84061086",
"0.84061086",
"0.8305336",
"0.8261747",
"0.8259579",
"0.8156888",
"0.81361055",
"0.81099844",
"0.81099844",
"0.7929717",
"0.7892565",
"0.77409184",
"0.76851505",
"0.7647363",
"0.7647363",
"0.7636787",
"0.7588299",
"0.75804627",
"0.7553916",
"0.7477552",
"0.73886... | 0.766505 | 13 |
Check if instance is ready. | def ready?
status == "RUNNING"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ready?\n @ready == true\n end",
"def ready?\n @is_ready\n end",
"def is_ready?\n return @ready\n end",
"def _ready?\n true\n end",
"def ready?\n true\n end",
"def ready?\n return _ready?\n rescue\n return false\n end",
"def rea... | [
"0.83741534",
"0.8345819",
"0.82622075",
"0.8227798",
"0.8177749",
"0.8109531",
"0.8028265",
"0.8028265",
"0.8028265",
"0.8028265",
"0.8028265",
"0.80181605",
"0.80033445",
"0.795451",
"0.790489",
"0.78897995",
"0.7853951",
"0.78305364",
"0.7806062",
"0.7806062",
"0.7796171",... | 0.7720416 | 21 |
this returns the orders that include items that have pallets, note: remember, an order has many items | def order_items_attributes=(order_items_attributes)
order_items_attributes.each do |i, order_item_attributes|
if check_for_inputs(order_item_attributes)
order_item = self.order_items.build(order_item_attributes)
if has_pallet(order_item.item)
pallet_counter(order_item)
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_orders\n return Order.where(:status => 'ordered', :dropper_id => nil, :picker_id => nil) if self.pickup_boy?\n end",
"def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end",
"def filter_order_items(merchant)\n self.orderitems.to_a.select { |orderi... | [
"0.61362827",
"0.59218144",
"0.5865025",
"0.5730014",
"0.56982267",
"0.561886",
"0.5576791",
"0.5569058",
"0.54928625",
"0.53727776",
"0.5370861",
"0.536861",
"0.53604424",
"0.52921283",
"0.5285972",
"0.5284274",
"0.5267683",
"0.52323484",
"0.5228819",
"0.52138084",
"0.521373... | 0.0 | -1 |
used by devise to redirect user after signing in | def signed_in_root_path(resource_or_scope)
if session[:return_to]
return session.delete(:return_to)
elsif resource_or_scope.is_a?(User) && resource_or_scope.teacher?
return teacher_dashboard_url
end
'/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_signed_in_user\n redirect_to user_home_path if user_signed_in?\n end",
"def sign_in_and_redirect(resource_or_scope, *args); end",
"def signed_in_user\n store_location #pour ensuite rediriger l'utilisateur vers la destination qu'il voulait avant\n # d'etre rediriger vers la... | [
"0.8116481",
"0.7991182",
"0.787982",
"0.7872794",
"0.78516376",
"0.7763101",
"0.7744784",
"0.77185047",
"0.77033526",
"0.77033526",
"0.76548886",
"0.7649883",
"0.76387495",
"0.76366997",
"0.7618446",
"0.76157314",
"0.76023173",
"0.75694543",
"0.7566812",
"0.75555867",
"0.753... | 0.0 | -1 |
most common letter in the array, and a count of how many times it appears. Difficulty: medium. | def get_letter_count(string)
letter_count = []
i = 0
while i < string.length
letter = string[i]
#check if letter has already been counted. If it has, add 1 to the count.
#If it hasn't, add an entry for it
j = 0
letter_counted = false
while j < letter_count.length
if letter_count[j][0] == letter
letter_count[j][1] += 1
letter_counted = true
break
end
j += 1
end
if !letter_counted
letter_count.push([letter, 1])
end
i += 1
end
return letter_count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_common_letter(string)\n # #create array, letter and count to return \n # mostCommon = []\n # count = 0\n # #assign the first letter to a variable\n # i = 0\n # #loop through array\n # while i < string.length\n # count = string.count(string[i])\n # for j in string\n # #count how many times ... | [
"0.7886281",
"0.76298076",
"0.7629645",
"0.7625376",
"0.75703573",
"0.751901",
"0.74115133",
"0.74026346",
"0.7384888",
"0.7335181",
"0.73200923",
"0.7238386",
"0.7209854",
"0.7206895",
"0.7202064",
"0.7185657",
"0.71706784",
"0.7141486",
"0.71382904",
"0.7076013",
"0.7045139... | 0.0 | -1 |
Show list of user's categories | def index
authorize! :view, Family
@spend_categories = SpendCategory.where(family_id: current_user.family.id)
@spend_categories.order("name DESC") if @spend_categories.present?
@income_categories = IncomeCategory.where(family_id: current_user.family.id)
@income_categories.order("name DESC") if @income_categories.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @categories = current_user.categories\n end",
"def index\n @categories = Category.where(user_id: current_user.id)\n end",
"def show\n @categories = Category.all\n @users = User.all\n end",
"def index\n ##########\n @category = current_user.category\n end",
"def index\n ... | [
"0.80658346",
"0.7665386",
"0.74115974",
"0.7400338",
"0.73943084",
"0.7276643",
"0.72379327",
"0.7153845",
"0.70810765",
"0.70159316",
"0.6951911",
"0.67997205",
"0.6778924",
"0.67536426",
"0.67459565",
"0.6743438",
"0.6718241",
"0.671222",
"0.6695024",
"0.6689378",
"0.66724... | 0.0 | -1 |
Create new user's category | def create
@category.family = current_user.family
authorize! :create, @category
if @category.save!
flash[:notice] = "Категория успешно добавлена"
else
flash[:alert] = "Ошибка добавления категории трат: #{@category.errors.full_messages}"
end
respond_to do |format|
format.html { redirect_to categories_path }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @category = Category.new(params[:user])\n if @category.save\n flash[:success] = \"Category created!\"\n redirect_to admin_path\n end\n end",
"def create\n @user = current_user\n @category = Category.new(params[:category])\n @user.categories << @category\n #TODO: error... | [
"0.8281246",
"0.81988573",
"0.79847276",
"0.7972657",
"0.77926004",
"0.7737562",
"0.7707187",
"0.76562417",
"0.7630072",
"0.7598694",
"0.7567798",
"0.7560255",
"0.7505386",
"0.7407378",
"0.7369527",
"0.7173446",
"0.71315706",
"0.7094427",
"0.7045219",
"0.69994515",
"0.6997210... | 0.72778684 | 15 |
Create new user's category | def update
if @category.update_attributes(params[:category])
flash[:notice] = "Категория успешно изменена"
else
flash[:alert] = "Ошибка изменения категории: #{@category.errors.full_messages}"
end
respond_to do |format|
format.html { redirect_to categories_path }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @category = Category.new(params[:user])\n if @category.save\n flash[:success] = \"Category created!\"\n redirect_to admin_path\n end\n end",
"def create\n @user = current_user\n @category = Category.new(params[:category])\n @user.categories << @category\n #TODO: error... | [
"0.8281246",
"0.81988573",
"0.79847276",
"0.7972657",
"0.77926004",
"0.7737562",
"0.7707187",
"0.76562417",
"0.7630072",
"0.7598694",
"0.7567798",
"0.7560255",
"0.7505386",
"0.7407378",
"0.7369527",
"0.72778684",
"0.7173446",
"0.71315706",
"0.7094427",
"0.7045219",
"0.6999451... | 0.0 | -1 |
this is actually a hack because of: | def user_name
self.user.name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def escaper=(_); end",
"def schubert; end",
"def escaper; end",
"def original; end",
"def internal; end",
"def anchored; end",
"def custom; end",
"def custom; end",
"def w... | [
"0.7131775",
"0.6203183",
"0.6138407",
"0.6138407",
"0.6138407",
"0.6138407",
"0.6059723",
"0.6015824",
"0.58304185",
"0.5744367",
"0.5731512",
"0.5699787",
"0.5688648",
"0.5688648",
"0.5667615",
"0.56662905",
"0.566061",
"0.566061",
"0.566061",
"0.5644378",
"0.5619236",
"0... | 0.0 | -1 |
this is actually a hack because of: | def user_gravatar_url
self.user.gravatar_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def escaper=(_); end",
"def schubert; end",
"def escaper; end",
"def original; end",
"def internal; end",
"def anchored; end",
"def custom; end",
"def custom; end",
"def w... | [
"0.7132914",
"0.62034553",
"0.6138249",
"0.6138249",
"0.6138249",
"0.6138249",
"0.60605013",
"0.60159487",
"0.58313113",
"0.5745575",
"0.5732996",
"0.5700088",
"0.56898683",
"0.56898683",
"0.5668269",
"0.5666841",
"0.5660855",
"0.5660855",
"0.5660855",
"0.56443393",
"0.561954... | 0.0 | -1 |
Gets a collection of instances. | def kitchen_instances(regexp, config)
instances = Kitchen::Config.new(config).instances
return instances if regexp.nil? || regexp == 'all'
instances.get_all(Regexp.new(regexp))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instances()\n return @instances\n end",
"def instances\n @instances ||= []\n end",
"def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end",
"def instances\n ... | [
"0.81485146",
"0.8025635",
"0.78746283",
"0.7508409",
"0.7477923",
"0.73616457",
"0.7337503",
"0.73172325",
"0.7315372",
"0.71781",
"0.7161049",
"0.6965459",
"0.68837464",
"0.66688204",
"0.6651144",
"0.66405267",
"0.66405267",
"0.66275734",
"0.6564848",
"0.6543731",
"0.653100... | 0.0 | -1 |
Runs a test kitchen action against some instances. | def run_kitchen(action, regexp, loader_config={})
action = 'test' if action.nil?
require 'kitchen'
Kitchen.logger = Kitchen.default_file_logger
config = {loader: Kitchen::Loader::YAML.new(loader_config)}
kitchen_instances(regexp, config).each { |i| i.send(action) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_kitchen(action, regexp, loader_config = {})\n action = 'test' if action.nil?\n require 'kitchen'\n Kitchen.logger = Kitchen.default_file_logger\n config = { loader: Kitchen::Loader::YAML.new(loader_config) }\n kitchen_instances(regexp, config).each { |i| i.send(action) }\n end",
"def run_... | [
"0.74731743",
"0.74731743",
"0.6719697",
"0.64891034",
"0.64788145",
"0.6213271",
"0.60598403",
"0.5918454",
"0.5862284",
"0.58484316",
"0.58397293",
"0.58116484",
"0.5801322",
"0.5792616",
"0.5770287",
"0.5745653",
"0.571535",
"0.570919",
"0.5694409",
"0.5680005",
"0.5656635... | 0.75357765 | 0 |
require access for authorized users | def authorize_user
@user = User.find(params[:id])
#User.find_by(id: (session[:update_email]/50000)) works with the code on line 50 of the sessions controller
#this is done to allow the user to update the email in the case that they do not receive a confirmation email
unless @user == User.find_by(id: session[:user_id]) || User.find_by(role_id: session[:user_role_id]) || User.find_by(id: (session[:update_email]/50000))
redirect_to login_url, notice: "Permission Denied.\nA different user login is required to access this page."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def require_auth(user)\n return head(:forbidden) unless current_user == user.account\n end",
"def require_auth\n head :unauthorized unless current_user\n end",
"def ensure_user\n current_user... | [
"0.77593964",
"0.7748209",
"0.7566036",
"0.7559076",
"0.7435289",
"0.7431012",
"0.7416132",
"0.7416132",
"0.7416132",
"0.74131775",
"0.7405572",
"0.7402952",
"0.73924214",
"0.7350881",
"0.73457175",
"0.7322151",
"0.727394",
"0.72719395",
"0.72653437",
"0.7235391",
"0.72302824... | 0.0 | -1 |
this stores the users location prior to logging in, it must be called within each individual controller to save the location. If the user location is not saved the user will be redirect_to the admin_url (control panel) | def store_location
session[:return_to] = request.url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_current_location\n store_location_for(:user, request.url)\n end",
"def store_location\n store_location_for(:user, params[:redirect_to]) if params[:redirect_to].present?\n\n # note: don't store the previous url on each call. this led to an issue where\n # missing asset might get run th... | [
"0.75684744",
"0.75506914",
"0.7434143",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7430859",
"0.7251956",
"0.7156981",
"0.7152388",
"0.7093034",
"0.70866597",
"0.7064003",
"0.70543873",
"0.7035692",... | 0.0 | -1 |
this function allows the user to be redirect_to to store_location (if it is something that was set in the controller) or will redirect_to the admin url | def redirect_back_or_default(default)
redirect_to(session[:return_to] || default, alert: "Login Successful, Welcome Back!")
session[:return_to] = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n store_location_for(:user, params[:redirect_to]) if params[:redirect_to].present?\n\n # note: don't store the previous url on each call. this led to an issue where\n # missing asset might get run through this code, causing the user to be redirected\n # to the missing asset during a... | [
"0.7174009",
"0.7133609",
"0.7119979",
"0.7105398",
"0.7078067",
"0.70274514",
"0.70181847",
"0.7005821",
"0.6990787",
"0.69629383",
"0.6958871",
"0.6952866",
"0.68590677",
"0.68590677",
"0.68369323",
"0.6810304",
"0.67977303",
"0.6780715",
"0.6739045",
"0.67335254",
"0.67327... | 0.0 | -1 |
Create new Security Group. Returns +true+ or an exception. ec2.create_security_group('default1',"Default allowing SSH, HTTP, and HTTPS ingress") => true | def create_security_group(name, description=nil)
# EC2 doesn't like an empty description...
description = "-" if description.right_blank?
link = generate_request("CreateSecurityGroup",
'GroupName' => name.to_s,
'GroupDescription' => description.to_s)
request_info(link, RightBoolResponseParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(name, desc=nil, addresses=[], ports=[], protocols=[], &each_group)\n desc ||= \"Security Group #{name}\"\n ret = @@ec2.create_security_group(:group_name => name, :group_description => desc)\n return false unless (ret && ret['return'] == 'true')\n authorize(name, addresses, po... | [
"0.8387396",
"0.7905075",
"0.78881156",
"0.77781475",
"0.77714765",
"0.7763541",
"0.7759279",
"0.7694768",
"0.76065594",
"0.738938",
"0.727987",
"0.72345024",
"0.7073336",
"0.703662",
"0.70174026",
"0.7007885",
"0.6961763",
"0.6961763",
"0.6953225",
"0.6948426",
"0.6930333",
... | 0.7775005 | 4 |
Remove Security Group. Returns +true+ or an exception. ec2.delete_security_group('default1') => true | def delete_security_group(name)
link = generate_request("DeleteSecurityGroup",
'GroupName' => name.to_s)
request_info(link, RightBoolResponseParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy(name, &each_group)\n list(name, &each_group) if each_group\n ret = @@ec2.delete_security_group(:group_name => name)\n (ret && ret['return'] == 'true')\n end",
"def delete_security_group(name)\n link = generate_request(\"DeleteSecurityGroup\", \n ... | [
"0.80487216",
"0.7882351",
"0.7882351",
"0.7744053",
"0.7643694",
"0.7437061",
"0.7221697",
"0.70399326",
"0.69053125",
"0.6839995",
"0.67417854",
"0.6633086",
"0.6592293",
"0.6551214",
"0.6385112",
"0.6295218",
"0.6288234",
"0.62862986",
"0.62296134",
"0.6219163",
"0.6193624... | 0.78630924 | 4 |
Edit AWS/Eucaliptus security group permissions. Options: action :authorize (or :grant) | :revoke (or :remove) group_name security group name permissions a combination of options below: :source_group_owner => UserId :source_group => GroupName :from_port => from port :to_port => to port :port => set both :from_port and to_port with the same value :protocol => :tcp | :udp | :icmp :cidr_ip => '0.0.0.0/0' ec2.edit_security_group( :grant, 'kdsgtest', :source_group => "sketchy", :source_group_owner => "600000000006", :protocol => 'tcp', :port => '80', :cidr_ip => '127.0.0.1/32') => true P.S. This method is deprecated for AWS and but still good for Eucaliptus clouds. Use +modify_security_group_ingress+ method for AWS clouds. | def edit_security_group(action, group_name, params)
hash = {}
case action
when :authorize, :grant then action = "AuthorizeSecurityGroupIngress"
when :revoke, :remove then action = "RevokeSecurityGroupIngress"
else raise "Unknown action #{action.inspect}!"
end
hash['GroupName'] = group_name
hash['SourceSecurityGroupName'] = params[:source_group] unless params[:source_group].right_blank?
hash['SourceSecurityGroupOwnerId'] = params[:source_group_owner].to_s.gsub(/-/,'') unless params[:source_group_owner].right_blank?
hash['IpProtocol'] = params[:protocol] unless params[:protocol].right_blank?
unless params[:port].right_blank?
hash['FromPort'] = params[:port]
hash['ToPort'] = params[:port]
end
hash['FromPort'] = params[:from_port] unless params[:from_port].right_blank?
hash['ToPort'] = params[:to_port] unless params[:to_port].right_blank?
hash['CidrIp'] = params[:cidr_ip] unless params[:cidr_ip].right_blank?
#
link = generate_request(action, hash)
request_info(link, RightBoolResponseParser.new(:logger => @logger))
rescue Exception
on_exception
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_security_group(action, group_name, params)\n hash = {}\n case action\n when :authorize, :grant then action = \"AuthorizeSecurityGroupIngress\"\n when :revoke, :remove then action = \"RevokeSecurityGroupIngress\"\n else raise \"Unknown action #{action.inspect}!\"\n end\n ... | [
"0.81268746",
"0.709222",
"0.6666446",
"0.6579435",
"0.6491505",
"0.6424893",
"0.6376085",
"0.6334054",
"0.6330171",
"0.6323978",
"0.6302062",
"0.625039",
"0.6233455",
"0.6233455",
"0.6142177",
"0.6080677",
"0.60651004",
"0.60216",
"0.60216",
"0.60012406",
"0.60012406",
"0.... | 0.811006 | 1 |
Authorize named ingress for security group. Allows instances that are member of someone else's security group to open connections to instances in my group. ec2.authorize_security_group_named_ingress('my_awesome_group', '701102198268', 'their_group_name') => true | def authorize_security_group_named_ingress(name, owner, group)
edit_security_group( :authorize, name, :source_group_owner => owner, :source_group => group)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize_security_group_named_ingress(name, owner, group)\n link = generate_request(\"AuthorizeSecurityGroupIngress\", \n 'GroupName' => name.to_s, \n 'SourceSecurityGroupName' => group.to_s, \n 'So... | [
"0.86713415",
"0.86639345",
"0.837866",
"0.7622326",
"0.7554448",
"0.726087",
"0.7230493",
"0.72296625",
"0.7143276",
"0.70738345",
"0.70681846",
"0.696578",
"0.696578",
"0.6691634",
"0.6691634",
"0.66828656",
"0.64780766",
"0.633106",
"0.6322198",
"0.614736",
"0.610229",
"... | 0.84743905 | 3 |
Revoke named ingress for security group. ec2.revoke_security_group_named_ingress('my_awesome_group', aws_user_id, 'another_group_name') => true | def revoke_security_group_named_ingress(name, owner, group)
edit_security_group( :revoke, name, :source_group_owner => owner, :source_group => group)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_security_group_named_ingress(name, owner, group)\n link = generate_request(\"RevokeSecurityGroupIngress\", \n 'GroupName' => name.to_s, \n 'SourceSecurityGroupName' => group.to_s, \n 'SourceSe... | [
"0.87961423",
"0.87834394",
"0.8537333",
"0.7403012",
"0.7352675",
"0.7352675",
"0.7296659",
"0.7296659",
"0.72954845",
"0.7290351",
"0.72594357",
"0.7220167",
"0.712856",
"0.712856",
"0.6918932",
"0.6834135",
"0.6722055",
"0.6722055",
"0.66983354",
"0.6632761",
"0.6617598",
... | 0.8762045 | 3 |
Add permission to a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp'. ec2.authorize_security_group_IP_ingress('my_awesome_group', 80, 82, 'udp', '192.168.1.0/8') => true ec2.authorize_security_group_IP_ingress('my_awesome_group', 1, 1, 'icmp') => true | def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
edit_security_group( :authorize, name, :from_port => from_port, :to_port => to_port, :protocol => protocol, :cidr_ip => cidr_ip )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorize_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n link = generate_request(\"AuthorizeSecurityGroupIngress\", \n 'GroupName' => name.to_s,\n 'IpProtocol' => protocol.to_s,\n ... | [
"0.76357865",
"0.7634434",
"0.7408715",
"0.66678315",
"0.6456444",
"0.627035",
"0.6226957",
"0.6021188",
"0.5970519",
"0.5970519",
"0.5938966",
"0.5929542",
"0.59208864",
"0.5910044",
"0.590678",
"0.58988553",
"0.58678806",
"0.58491343",
"0.58429354",
"0.57454664",
"0.5736044... | 0.7573297 | 3 |
Remove permission from a security group. Returns +true+ or an exception. +protocol+ is one of :'tcp'|'udp'|'icmp' ('tcp' is default). ec2.revoke_security_group_IP_ingress('my_awesome_group', 80, 82, 'udp', '192.168.1.0/8') => true | def revoke_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')
edit_security_group( :revoke, name, :from_port => from_port, :to_port => to_port, :protocol => protocol, :cidr_ip => cidr_ip )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_security_group_IP_ingress(name, from_port, to_port, protocol='tcp', cidr_ip='0.0.0.0/0')\n link = generate_request(\"RevokeSecurityGroupIngress\", \n 'GroupName' => name.to_s, \n 'IpProtocol' => protocol.to_s, \n ... | [
"0.76608306",
"0.7658232",
"0.75060755",
"0.68332356",
"0.6516533",
"0.6502954",
"0.64896923",
"0.6414689",
"0.6414689",
"0.63920975",
"0.6388912",
"0.6231157",
"0.6231157",
"0.61790323",
"0.61790323",
"0.6046019",
"0.60283333",
"0.5993239",
"0.5956533",
"0.5923145",
"0.57858... | 0.7537076 | 3 |
GET /add_questions GET /add_questions.json | def index
@add_questions = AddQuestion.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_question\n form_param = params.require(:form).permit(:id)\n\n render json: Question.add_new_question(form_param)\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno ... | [
"0.7837309",
"0.7652263",
"0.7514377",
"0.6960034",
"0.68619883",
"0.6838369",
"0.67615575",
"0.6642057",
"0.6621409",
"0.6619214",
"0.6594766",
"0.6568661",
"0.65264106",
"0.65135425",
"0.6435204",
"0.64320576",
"0.63952327",
"0.63774574",
"0.63586694",
"0.63557065",
"0.6353... | 0.6802705 | 6 |
GET /add_questions/1 GET /add_questions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_question\n form_param = params.require(:form).permit(:id)\n\n render json: Question.add_new_question(form_param)\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno ... | [
"0.78758836",
"0.7548497",
"0.74923605",
"0.68435454",
"0.6835455",
"0.68255997",
"0.6807863",
"0.68028915",
"0.6789703",
"0.67193544",
"0.67060614",
"0.66581166",
"0.6649253",
"0.6633282",
"0.6633282",
"0.6633282",
"0.6633282",
"0.6633282",
"0.6613763",
"0.6609229",
"0.65896... | 0.0 | -1 |
POST /add_questions POST /add_questions.json | def create
@add_question = AddQuestion.new(add_question_params)
respond_to do |format|
if @add_question.save
format.json { head :no_content }
else
format.html { render :new }
format.json { render json: @add_question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_question\n form_param = params.require(:form).permit(:id)\n\n render json: Question.add_new_question(form_param)\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno ... | [
"0.7852975",
"0.7795841",
"0.7109214",
"0.7104634",
"0.70183116",
"0.6987",
"0.6976631",
"0.69180155",
"0.68319684",
"0.6784938",
"0.67814356",
"0.6735102",
"0.67156875",
"0.669168",
"0.6674877",
"0.6658889",
"0.66518444",
"0.6651792",
"0.6651792",
"0.6640994",
"0.6640994",
... | 0.7700928 | 2 |
PATCH/PUT /add_questions/1 PATCH/PUT /add_questions/1.json | def update
respond_to do |format|
if @add_question.update(add_question_params)
format.html { redirect_to @add_question, notice: 'Add question was successfully updated.' }
format.json { render :show, status: :ok, location: @add_question }
else
format.html { render :edit }
format.json { render json: @add_question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end",
"def add_question\n form_param = params.require(:form).permit(:id... | [
"0.6845491",
"0.6743904",
"0.66916203",
"0.6671856",
"0.66711247",
"0.6546443",
"0.65170646",
"0.6508519",
"0.6504837",
"0.65031534",
"0.645796",
"0.6443054",
"0.63987464",
"0.6385454",
"0.63840485",
"0.6382238",
"0.6375955",
"0.63715976",
"0.6363509",
"0.6328778",
"0.6328778... | 0.691498 | 0 |
DELETE /add_questions/1 DELETE /add_questions/1.json | def destroy
@add_question.destroy
respond_to do |format|
format.html { redirect_to add_questions_url, notice: 'Add question was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_question\n question_params = params.permit(:id, :form_id, :question_type_id)\n\n render json: Question.delete_question(question_params)\n end",
"def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n rend... | [
"0.7835398",
"0.7685678",
"0.7626875",
"0.7584814",
"0.74746704",
"0.74725556",
"0.74476784",
"0.739845",
"0.73834914",
"0.73721164",
"0.73721164",
"0.7360046",
"0.73573726",
"0.73573726",
"0.73573726",
"0.73573726",
"0.73573726",
"0.73573726",
"0.733195",
"0.73310745",
"0.73... | 0.768047 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_add_question
@add_question = AddQuestion.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 add_question_params
params.require(:add_question).permit(:content, :mark_id, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
GET /rounds GET /rounds.json | def index
championship = Championship.find_by_desc($current_championship)
unless championship == nil?
@rounds = Round.get_all_rounds_by_championship_id(championship.id, params[:page])
end
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @rounds }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def index\n @rounds = Round.all\n end",
"def index\n @rounds = Round.all\n end",
"def index\n @rounds = Round.all\n end",
"def index\n @rounds = Round.all\n end",
"def index\n @rounds = Round.all\n ... | [
"0.8179578",
"0.7259982",
"0.7259982",
"0.7259982",
"0.7259982",
"0.7259982",
"0.7259982",
"0.7259982",
"0.7138636",
"0.7110566",
"0.69381267",
"0.69308823",
"0.69218105",
"0.6695108",
"0.66559047",
"0.6504946",
"0.6480924",
"0.6423685",
"0.64184344",
"0.6388241",
"0.6317415"... | 0.6681436 | 14 |
GET /rounds/1 GET /rounds/1.json | def show
@round = Round.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @round }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def show\n @game = Game.where(user_id: current_user.id).find(params[:game_id])\n @round = @game.rounds.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: ... | [
"0.7735423",
"0.7122611",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.6970371",
"0.69027627",
"0.689435",
"0.6834668",
"0.68254834",
"0.6753524",
"0.66504645",
"0.6631633",
"0.65709615",
"0.65156215",
"0.64609367",
"0.6414302",
"0.6409868"... | 0.6745448 | 14 |
GET /rounds/new GET /rounds/new.json | def new
@championships = Championship.all
@round = Round.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @round }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @game = Game.where(user_id: current_user.id).find(params[:game_id])\n # @new_round = @game.rounds.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @round }\n end\n end",
"def new\n @round = Round.new\n\n respond_to do |format|\n ... | [
"0.7823347",
"0.7768234",
"0.7062128",
"0.7037856",
"0.6989108",
"0.698715",
"0.698715",
"0.69156754",
"0.68769395",
"0.6836148",
"0.6825563",
"0.6796785",
"0.6749431",
"0.67021143",
"0.6658779",
"0.6651383",
"0.66297877",
"0.66250575",
"0.6618303",
"0.6611059",
"0.6611059",
... | 0.6947014 | 7 |
POST /rounds POST /rounds.json | def create
@round = Round.new(params[:round])
params[:round][:start_date] = Date.strptime(params[:round][:start_date], '%d/%m/%Y').strftime.to_s
params[:round][:end_date] = Date.strptime(params[:round][:end_date], '%d/%m/%Y').strftime.to_s
if params[:championship][:championship_id] == ""
respond_to do |format|
flash[:error] = "Voce deve selecionar o campeonato"
format.html { render :action => "new" }
end
else
@championship = Championship.find(params[:championship][:championship_id])
@last_round4_championship = Round.find_by_championship_id(@championship.id)
@round.championship = @championship
num_round = (@last_round4_championship == nil)? 1 : Round.maximum(:num_round) +1
@round.num_round = num_round
respond_to do |format|
if @round.save
format.html { redirect_to @round, :notice => 'Round was successfully created.' }
format.json { render :json => @round, :status => :created, :location => @round }
else
format.html { render :action => "new" }
format.json { render :json => @round.errors, :status => :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rounds\n Round.create_rounds(id)\n\n\n end",
"def create_rounds\n Round.create_rounds(id)\n\n\n end",
"def create\n @round = @tournament.rounds.build(round_params)\n\n respond_to do |format|\n if @round.save\n format.html do redirect_to @round, notice: 'Round was successful... | [
"0.7102363",
"0.7102363",
"0.7003111",
"0.6988971",
"0.69062513",
"0.6889115",
"0.683185",
"0.6822799",
"0.68033063",
"0.6803029",
"0.66738534",
"0.6663299",
"0.6570075",
"0.65617675",
"0.6538201",
"0.6487796",
"0.6377657",
"0.6377657",
"0.6377002",
"0.6375294",
"0.63667196",... | 0.60049534 | 35 |
PUT /rounds/1 PUT /rounds/1.json | def update
@round = Round.find(params[:id])
params[:round][:start_date] = Date.strptime(params[:round][:start_date], '%d/%m/%Y').strftime.to_s
params[:round][:end_date] = Date.strptime(params[:round][:end_date], '%d/%m/%Y').strftime.to_s
respond_to do |format|
if @round.update_attributes(params[:round])
format.html { redirect_to @round, :notice => 'Round was successfully updated.' }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @round.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @game = Game.where(user_id: current_user.id).find(params[:game_id])\n @round = @game.rounds.find(params[:id])\n\n respond_to do |format|\n if @round.update_attributes(params[:round])\n format.html { redirect_to @round, notice: 'Round was successfully updated.' }\n format.js... | [
"0.6796027",
"0.6724217",
"0.6655491",
"0.64874786",
"0.64874786",
"0.64816874",
"0.64465266",
"0.6438805",
"0.6435982",
"0.64343923",
"0.6410346",
"0.6410346",
"0.6397628",
"0.636422",
"0.63572305",
"0.62369597",
"0.6140355",
"0.6082027",
"0.60405225",
"0.5963225",
"0.585815... | 0.5805351 | 22 |
DELETE /rounds/1 DELETE /rounds/1.json | def destroy
@round = Round.find(params[:id])
@round.destroy
respond_to do |format|
format.html { redirect_to rounds_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @round = Round.find(params[:id])\n @round.destroy\n\n respond_to do |format|\n format.html { redirect_to(rounds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @round = Round.find(params[:id])\n @round.destroy\n\n respond_to do |format|\n format.h... | [
"0.7431568",
"0.7431568",
"0.7430822",
"0.7422256",
"0.72982204",
"0.72982204",
"0.72982204",
"0.72982204",
"0.7291912",
"0.72501194",
"0.72139317",
"0.7098678",
"0.69999164",
"0.6967715",
"0.6926577",
"0.69074655",
"0.68914616",
"0.68591595",
"0.68037254",
"0.66976833",
"0.6... | 0.76205236 | 2 |
Method to make key/value pairs and to sort values into boolean, integer and string input. Also handles addresses, which would otherwise come out as integers, and 0 input for children/pets which would otherwise come out as a string. | def key_maker(hash, key, value)
case
when value.include?("true")
value = true
when value.include?("false")
value = false
when value.to_i > 0 && value.length < 4
value = value.to_i
when value == "0"
value = value.to_i
else
value
end
hash.store(key.to_sym, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_data_type(client_data)\n client_data.each {|client_key, client_value|\n#check for data that should be integers\n if client_key == :age || client_key == :number_children\n client_data[client_key] = client_value.to_i\n#check for data that should be true or false\n elsif client_key == :is_house_over_... | [
"0.56923467",
"0.55920357",
"0.559008",
"0.53408206",
"0.52656025",
"0.523438",
"0.5206856",
"0.51642907",
"0.513837",
"0.5067781",
"0.5064826",
"0.5060533",
"0.50026995",
"0.5001606",
"0.4966276",
"0.49653393",
"0.4963957",
"0.4950396",
"0.49435326",
"0.49419338",
"0.4935293... | 0.63050044 | 0 |
Save in 'filename' the list of domains in RPZ format | def write_rpz_domain(fd, domain)
if domain[-1] == '.' then
domain = domain[0..-2]
end
if domain[0] == '.' then
domain = domain[1..-1]
end
return unless /[\.]/.match(domain)
fd.write(domain + " IN CNAME .\n")
fd.write("*." + domain + " IN CNAME .\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_sub_domains_to_file!(file_domains=@file_sub_domains, domains=@known_internet_sub_domains)\n\t\tputs \"Saving the current domains cache table from memory to file: #{file_domains} ...\" if @verbose\n\t\ttimestamp=Time.now\n\t\tf=File.open(file_domains, 'w')\n\t\tf.write \"# Local domains file created by cla... | [
"0.66344064",
"0.6118075",
"0.61124873",
"0.6090675",
"0.5979058",
"0.5979058",
"0.58664614",
"0.58655226",
"0.58185613",
"0.57401264",
"0.5734652",
"0.57338697",
"0.5712392",
"0.5689902",
"0.5679455",
"0.56416655",
"0.55351734",
"0.5521206",
"0.55106854",
"0.54686594",
"0.54... | 0.65315515 | 1 |
Parse a shalla input file and write its content in a new RPZ file. Removes all characters after / (including '/') removes all IP address (not usable by RPZ) | def convert_file(input, output)
nb = 0
fd = File.new(output, "w")
File.foreach(input) { |address|
address.chop!
if not /^\d+\.\d+\.\d+\.\d+$/.match(address) then
if not $dns_ok.include?(address) then
write_rpz_domain(fd, address)
nb = nb + 1
end
end
}
fd.close
nb
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splitByFile\n outfile = nil\n stream = open(@filename)\n until (stream.eof?)\n line = stream.readline\n\n # we need to create a new file\n if (line =~ /--- .*/) == 0\n if (outfile) \n outfile.close_write\n en... | [
"0.5583923",
"0.54376125",
"0.5324565",
"0.5257735",
"0.52382654",
"0.5171743",
"0.5164576",
"0.51153535",
"0.50748205",
"0.5053873",
"0.50230414",
"0.49622926",
"0.49479944",
"0.49412212",
"0.49357307",
"0.4908203",
"0.48666462",
"0.48547953",
"0.48370633",
"0.48248672",
"0.... | 0.57342464 | 0 |
Reads the old zone file and looks for the current serial Returns the serial if found The SOA line must be of the form : | def get_zone_serial(file)
found_soa = false
File.foreach(file) { |line|
if not found_soa then
found_soa = true if /^@\s+IN\s+SOA/.match(line)
else
if /^\s*(\d{10})\s+/.match(line) then
return $1
end
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_serial(zonefile)\n date_string = Date.today.to_s.delete('-')\n IO.foreach(zonefile) do |line|\n if line =~ / ; serial$/\n serial, semicolon, info = line.split\n if serial.chop.chop.to_i == date_string.to_i\n new_serial = serial.to_i + 1\n else\n new_serial = date_string + ... | [
"0.6439941",
"0.6079188",
"0.5611845",
"0.5261548",
"0.5260999",
"0.5246058",
"0.52223474",
"0.5172741",
"0.5164461",
"0.51602376",
"0.51027524",
"0.5066086",
"0.5057783",
"0.50389385",
"0.49106145",
"0.48821047",
"0.4864515",
"0.48605916",
"0.48516092",
"0.48178408",
"0.4817... | 0.7574177 | 0 |
Increment the serial of zone file. If same day, only increment counter, else use the new day... | def inc_zone_serial(s)
now = Time.new
/(\d{4})(\d{2})(\d{2})(\d{2})/.match(s)
y = $1.to_i
m = $2.to_i
d = $3.to_i
c = $4.to_i
c = (y != now.year or m != now.month or d != now.day) ? 1 : c + 1
sprintf("%d%02d%02d%02d", now.year, now.month, now.day, c)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_serial(zonefile)\n date_string = Date.today.to_s.delete('-')\n IO.foreach(zonefile) do |line|\n if line =~ / ; serial$/\n serial, semicolon, info = line.split\n if serial.chop.chop.to_i == date_string.to_i\n new_serial = serial.to_i + 1\n else\n new_serial = date_string + ... | [
"0.7303657",
"0.69069767",
"0.62865156",
"0.5856992",
"0.5841115",
"0.57743907",
"0.5745232",
"0.5658456",
"0.5552205",
"0.55174154",
"0.5443754",
"0.54403585",
"0.5430161",
"0.5416888",
"0.5415341",
"0.5415341",
"0.53993815",
"0.53756225",
"0.5369849",
"0.531939",
"0.531259"... | 0.7188195 | 1 |
Generates a new zone.rpz file in /etc/bind Backup the file and increments the serial Provide one line per include of RPZ list file made from shalla domains list | def gen_zone_file(f, outputs)
serial = get_zone_serial(f)
if serial then
File.rename(f, f + '.bak')
new_serial = inc_zone_serial(serial)
fd = File.new(f, 'w')
fd.write($zone_header.gsub("$SERIAL$", new_serial))
fd.write("\n")
fd.write("$INCLUDE \"/etc/bind/rpz/local\";\n\n")
outputs.each { |out|
fd.write("$INCLUDE \"#{out}\";\n")
}
else
puts("No serial found in #{f}")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_serial(zonefile)\n date_string = Date.today.to_s.delete('-')\n IO.foreach(zonefile) do |line|\n if line =~ / ; serial$/\n serial, semicolon, info = line.split\n if serial.chop.chop.to_i == date_string.to_i\n new_serial = serial.to_i + 1\n else\n new_serial = date_string + ... | [
"0.64239585",
"0.6066277",
"0.59696627",
"0.55222404",
"0.54659384",
"0.5427846",
"0.5426534",
"0.54067296",
"0.53414124",
"0.53063905",
"0.527672",
"0.52684826",
"0.51421183",
"0.51210797",
"0.51118654",
"0.5111598",
"0.5092235",
"0.504426",
"0.50398093",
"0.5023304",
"0.501... | 0.7248609 | 0 |
Loads the user object from the database. | def load
@user ||= User.find(@id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_user\n @user = User.find(params[:user_id])\n end",
"def load_user\n if session[:user_id]\n @current_user = User.where(id: session[:user_id]).first\n end\n\n if !@current_user\n @current_user = User.create\n session[:user_id] = @current_user.id\n end\n end",
"def user\n ... | [
"0.7536621",
"0.7376823",
"0.6989149",
"0.696953",
"0.68652654",
"0.68652654",
"0.6854228",
"0.68365115",
"0.6818907",
"0.6741518",
"0.6649294",
"0.6629841",
"0.6609072",
"0.64798397",
"0.6473052",
"0.6446903",
"0.64141226",
"0.6306745",
"0.6297005",
"0.6292948",
"0.6270813",... | 0.8137732 | 0 |
Sign the current_user out | def sign_out
if active_token = ActiveToken.find_by_device(current_device)
active_token.destroy
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_out\n @current_user = nil\n end",
"def sign_out\n session.delete :user_id\n @current_user = nil\n end",
"def sign_out\n reset_session\n @current_user = nil\n end",
"def sign_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def signout\n session.delet... | [
"0.88684815",
"0.8740275",
"0.8577353",
"0.8568558",
"0.84131587",
"0.8409082",
"0.83575416",
"0.8344515",
"0.8344515",
"0.8344515",
"0.8344515",
"0.8344515",
"0.83085245",
"0.8302519",
"0.82874477",
"0.828644",
"0.8257942",
"0.8257239",
"0.82552314",
"0.82543004",
"0.8251006... | 0.0 | -1 |
include Overwatch::CommonData Consumes anything with this arg and returns a dict. Replaces parts with just the user query. | def consume_options(parts)
options = {}
parts.each_slice(2) do |arg|
if arg.size == 2 and arg[0].size > 1
arg[0] = arg[0][1..-1].to_sym
arg[1] = arg[1].to_sym
if @@option_aliases.has_key?(arg[0]) and @@arg_aliases.has_key?(arg[1])
options[@@option_aliases[arg[0]]] = @@arg_aliases[arg[1]]
end
end
end
query = parts.last
parts.clear
parts << query
options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_hash p={}\n\t\t\turl = case \n\t\t\t\twhen p[:url] == :referer \n\t\t\t\t\trequest.referer\n\t\t\t\twhen p[:url].is_a?(String)\n\t\t\t\t\tp[:url]\n\t\t\t\telse \n\t\t\t\t\trequest.url\n\t\t\t\tend\n\n\t\t\tquery = URI::parse(url).query\n\t\t\tquery.gsub!(\"metric=\",\"metric[]=\") if query\n\t\t\tquery.g... | [
"0.5741727",
"0.5623448",
"0.5592238",
"0.5536887",
"0.552523",
"0.55247915",
"0.5521305",
"0.5501268",
"0.5501268",
"0.5501268",
"0.5501268",
"0.5497067",
"0.54891205",
"0.5478288",
"0.54765284",
"0.5462666",
"0.54559773",
"0.5428477",
"0.5427384",
"0.5423512",
"0.54087406",... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.