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 |
|---|---|---|---|---|---|---|
GET /egresos/1 GET /egresos/1.json | def activo
@egreso.activo
respond_to do |format|
format.html { redirect_to egresos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @ordenes = Orden.all\n\n respo... | [
"0.66960174",
"0.66495717",
"0.6387145",
"0.6371378",
"0.63597155",
"0.63475263",
"0.6303454",
"0.62895095",
"0.6270849",
"0.6258465",
"0.62435913",
"0.62270004",
"0.62261194",
"0.61769146",
"0.61631995",
"0.61617047",
"0.6160539",
"0.61592335",
"0.61469007",
"0.61464125",
"0... | 0.0 | -1 |
POST /egresos POST /egresos.json | def create
@egreso = Egreso.new(egreso_params)
@total=dinero_actual
if @egreso.monto>@total
flash[:warning] = 'El monto de egreso no puede ser mayor al monto actual'
render action: "new"
else
if @egreso.save
flash[:success] = 'Egreso creado exitosamente'
redirect_to '/egresos'
else
render action: "new"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @eou = Eou.new(params[:eou])\n\n respond_to do |format|\n if @eou.save\n format.html { redirect_to @eou, :notice => 'Eou was successfully created.' }\n format.json { render :json => @eou, :status => :created, :location => @eou }\n else\n format.html { render :actio... | [
"0.60420245",
"0.602751",
"0.60156673",
"0.597133",
"0.59489936",
"0.591894",
"0.5902601",
"0.5895046",
"0.5871225",
"0.58207285",
"0.57962465",
"0.57889885",
"0.577726",
"0.5763865",
"0.57586485",
"0.57469255",
"0.5686293",
"0.56798947",
"0.567445",
"0.56469846",
"0.5621712"... | 0.0 | -1 |
PATCH/PUT /egresos/1 PATCH/PUT /egresos/1.json | def update
@egreso = Egreso.find(params[:id])
@total=dinero_actual
if @egreso.update(egreso_params)
if @egreso.monto>@total
flash[:warning] = 'El monto de egreso no puede ser mayor al monto actual'
render action: "edit"
else
flash[:success] = "Egreso actualizado exitosamente"
redirect_to '/egresos'
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\... | [
"0.6490069",
"0.6490069",
"0.6449782",
"0.63338315",
"0.6240615",
"0.6197203",
"0.6178819",
"0.6178819",
"0.61497384",
"0.6121692",
"0.6120058",
"0.6079346",
"0.604075",
"0.5971646",
"0.5971113",
"0.5961105",
"0.5919049",
"0.5917754",
"0.591378",
"0.58883876",
"0.5879796",
... | 0.0 | -1 |
DELETE /egresos/1 DELETE /egresos/1.json | def destroy
@egreso.destroy
respond_to do |format|
format.html { redirect_to egresos_url, notice: 'Egreso was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @resto.destroy\n respond_to do |format|\n format.html { redirect_to restos_url, notice: 'Entry was deleted.' }\n format.j... | [
"0.7137471",
"0.7045211",
"0.6996932",
"0.696007",
"0.695888",
"0.68278784",
"0.6800615",
"0.6786448",
"0.6786325",
"0.678618",
"0.6777188",
"0.67682195",
"0.6759223",
"0.67535365",
"0.67526776",
"0.67417103",
"0.67417103",
"0.67316526",
"0.6723328",
"0.67116386",
"0.67010766... | 0.7179799 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_egreso
@egreso = Egreso.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 egreso_params
params.require(:egreso).permit(:estado, :monto, :fecha, :concepto)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /virtual_assignments GET /virtual_assignments.xml | def index
special_joins = {}
## BUILD MASTER HASH WITH ALL SUB-PARAMS ##
allparams = {}
allparams[:mainmodel] = VirtualAssignment
allparams[:webparams] = params
allparams[:special_joins] = special_joins
results = Search.new(allparams).search
flash[:error] = results[:errors].join('<br />') unless results[:errors].empty?
includes = results[:includes]
results[:requested_includes].each_pair{|k,v| includes[k] = v}
@objects = results[:search_results]
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @objects.to_xml(:dasherize => false) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end",
"def show\n @virtual_assignment = @object\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml {... | [
"0.6637697",
"0.6236051",
"0.614057",
"0.5941413",
"0.5779441",
"0.5718009",
"0.5718009",
"0.5718009",
"0.5718009",
"0.5694754",
"0.5692379",
"0.5641",
"0.5634241",
"0.5632164",
"0.5620639",
"0.55808663",
"0.55584",
"0.552809",
"0.55277765",
"0.54885304",
"0.54813457",
"0.5... | 0.0 | -1 |
GET /virtual_assignments/1 GET /virtual_assignments/1.xml | def show
@virtual_assignment = @object
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @virtual_assignment.to_xml(:dasherize => false) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end",
"def index\n @assignments = Assignment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml ... | [
"0.65502846",
"0.62129265",
"0.61084586",
"0.6005439",
"0.5856372",
"0.5856372",
"0.5789025",
"0.57328445",
"0.5596506",
"0.55791974",
"0.5557281",
"0.5557281",
"0.5557281",
"0.5557281",
"0.5512219",
"0.54899293",
"0.5450475",
"0.5450208",
"0.54385656",
"0.54090863",
"0.53995... | 0.6513034 | 1 |
POST /virtual_assignments POST /virtual_assignments.xml | def create
@virtual_assignment = VirtualAssignment.new(params[:virtual_assignment])
vmhost = Node.find(params[:virtual_assignment][:parent_id])
return unless filter_perms(@auth,vmhost,['updater'])
vmguest = Node.find(params[:virtual_assignment][:child_id])
return unless filter_perms(@auth,vmguest,['updater'])
respond_to do |format|
if @virtual_assignment.save
format.html {
flash[:notice] = 'VirtualAssignment was successfully created.'
redirect_to virtual_assignment_url(@virtual_assignment)
}
format.js {
render(:update) { |page|
page.replace_html 'virtual_assignments', :partial => 'nodes/virtual_assignments', :locals => { :node => @virtual_assignment.virtual_host }
page.hide 'create_virtual_assignment'
page.show 'add_virtual_assignment_link'
}
}
format.xml { head :created, :location => virtual_assignment_url(@virtual_assignment) }
else
format.html { render :action => "new" }
format.js { render(:update) { |page| page.alert(@virtual_assignment.errors.full_messages) } }
format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @assignment = @user.assignments.new(params[:assignment])\n\n respond_to do |format|\n if @assignment.save\n flash[:notice] = 'Committee assignment was successfully created'\n format.html { redirect_to user_assignments_path(@user) }\n format.xml { render :xml => @assign... | [
"0.54020363",
"0.539747",
"0.53957725",
"0.5348445",
"0.52971923",
"0.52452",
"0.52233154",
"0.5192308",
"0.51903135",
"0.51874",
"0.51797116",
"0.5127008",
"0.5074702",
"0.5059835",
"0.5046715",
"0.5032332",
"0.503071",
"0.5029944",
"0.50034195",
"0.49964076",
"0.49663347",
... | 0.60104024 | 0 |
PUT /virtual_assignments/1 PUT /virtual_assignments/1.xml | def update
@virtual_assignment = @object
vmhost = @virtual_assignment.parent
return unless filter_perms(@auth,vmhost,['updater'])
vmguest = @virtual_assignment.child
return unless filter_perms(@auth,vmguest,['updater'])
respond_to do |format|
if @virtual_assignment.update_attributes(params[:virtual_assignment])
flash[:notice] = 'VirtualAssignment was successfully updated.'
format.html { redirect_to virtual_assignment_url(@virtual_assignment) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @virtual_assignment.errors.to_xml, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # Find the assignment and update it\n entry = Relationship.find(params[:id])\n entry.update_attributes(assignment_parameters)\n \n @active=\"assignments\"\n redirect_to \"/manage\"\n end",
"def update\n @assignment.status = params[:status]\n @assign... | [
"0.5625191",
"0.5607195",
"0.5492747",
"0.54851884",
"0.5478726",
"0.54490346",
"0.54326344",
"0.5364584",
"0.5313464",
"0.5277994",
"0.5265761",
"0.52302",
"0.52302",
"0.52302",
"0.5218662",
"0.51992226",
"0.51832354",
"0.5162778",
"0.51611555",
"0.51515114",
"0.5151385",
... | 0.62716335 | 0 |
DELETE /virtual_assignments/1 DELETE /virtual_assignments/1.xml | def destroy
@virtual_assignment = @object
@virtual_host = @virtual_assignment.virtual_host
return unless filter_perms(@auth,@virtual_host,['updater'])
@virtual_guest = @virtual_assignment.virtual_guest
return unless filter_perms(@auth,@virtual_guest,['updater'])
begin
@virtual_assignment.destroy
rescue Exception => destroy_error
respond_to do |format|
format.html {
flash[:error] = destroy_error.message
redirect_to virtual_assignment_url(@virtual_assignment) and return
}
format.js { render(:update) { |page| page.alert(destroy_error.message) } }
format.xml { head :error } # FIXME?
end
return
end
# Success!
respond_to do |format|
format.html { redirect_to virtual_assignments_url }
format.js {
render(:update) { |page|
page.replace_html 'virtual_assignments', {:partial => 'nodes/virtual_assignments', :locals => { :node => @virtual_host} }
}
}
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n CONNECTION.execute(\"DELETE FROM assignments WHERE id = #{self.id};\")\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete\n # Delete the assignment\n Relati... | [
"0.65508085",
"0.64016503",
"0.6292247",
"0.625738",
"0.6118638",
"0.5990139",
"0.5989626",
"0.59828377",
"0.595993",
"0.59377927",
"0.5932665",
"0.5923473",
"0.59099764",
"0.59087515",
"0.5897201",
"0.5893094",
"0.58808666",
"0.5868023",
"0.58524036",
"0.58322734",
"0.582633... | 0.59106106 | 12 |
GET /booking_tours GET /booking_tours.json | def index
@booking_tours = BookingTour.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tour_bookings = TourBooking.all\n end",
"def show\n render json: @booking\n end",
"def show\n render json: @booking\n end",
"def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end",
"def index\n @bookings = Booking.all\n\n render js... | [
"0.7233231",
"0.6457808",
"0.6457808",
"0.6455971",
"0.6416842",
"0.6416163",
"0.64058053",
"0.6380556",
"0.6372369",
"0.6340215",
"0.6327298",
"0.6327298",
"0.6306727",
"0.6294917",
"0.6277201",
"0.6273054",
"0.62478614",
"0.622166",
"0.6192561",
"0.61861825",
"0.61783314",
... | 0.76432353 | 0 |
GET /booking_tours/1 GET /booking_tours/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @booking_tours = BookingTour.all\n end",
"def index\n @tour_bookings = TourBooking.all\n end",
"def show\n render json: { booking: @booking }, status: 200\n end",
"def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend",
"def show\n render json: @booking\n... | [
"0.7388441",
"0.70917696",
"0.6859369",
"0.68357086",
"0.6799559",
"0.6799559",
"0.6739871",
"0.65724206",
"0.65724206",
"0.65724206",
"0.65724206",
"0.657155",
"0.6530873",
"0.65236825",
"0.648147",
"0.64135426",
"0.63697135",
"0.636405",
"0.6340944",
"0.63092804",
"0.630697... | 0.0 | -1 |
POST /booking_tours POST /booking_tours.json | def create
@booking_tour = BookingTour.new(booking_tour_params)
# need change after
@tour = Tour.find(@booking_tour.tour_id)
@user = User.find(@booking_tour.user_id)
@booking_tour.total_cost = params[:booking_tour][:number_of_people].to_i*@tour.price.to_i
respond_to do |format|
if @booking_tour.save
format.html { redirect_to @booking_tour, notice: 'Booking tour was successfully created.' }
format.json { render :show, status: :created, location: @booking_tour }
else
format.html { render :new }
format.json { render json: @booking_tour.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tour_booking = TourBooking.new(tour_booking_params)\n\n respond_to do |format|\n if @tour_booking.save\n format.html { redirect_to @tour_booking, notice: 'Tour booking was successfully created.' }\n format.json { render :show, status: :created, location: @tour_booking }\n ... | [
"0.6974891",
"0.66250515",
"0.6562384",
"0.64401764",
"0.640652",
"0.6373631",
"0.63238",
"0.63194263",
"0.63194263",
"0.6314086",
"0.6229027",
"0.6221234",
"0.621979",
"0.621599",
"0.6206846",
"0.6179224",
"0.6176186",
"0.6169112",
"0.6138127",
"0.6131413",
"0.6129685",
"0... | 0.6111078 | 22 |
PATCH/PUT /booking_tours/1 PATCH/PUT /booking_tours/1.json | def update
@booking_tour.total_cost = @booking_tour.number_of_people.to_i*@tour.price.to_i
respond_to do |format|
if @booking_tour.update(booking_tour_params)
format.html { redirect_to @booking_tour, notice: 'Booking tour was successfully updated.' }
format.json { render :show, status: :ok, location: @booking_tour }
else
format.html { render :edit }
format.json { render json: @booking_tour.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @tour.update(tour_params)\n booking = Booking.find_by(tour_id: @tour.id)\n booking.fill_available_seats unless booking.nil?\n format.html { redirect_to @tour, notice: 'Tour was successfully updated.' }\n format.json { render :show, status... | [
"0.72527105",
"0.7207738",
"0.6904247",
"0.69001466",
"0.6874737",
"0.68597555",
"0.6831179",
"0.68184495",
"0.68184495",
"0.68184495",
"0.6812191",
"0.6782855",
"0.6778548",
"0.6758355",
"0.6758355",
"0.6758355",
"0.67571443",
"0.67536205",
"0.6751031",
"0.67438704",
"0.6743... | 0.61339504 | 85 |
DELETE /booking_tours/1 DELETE /booking_tours/1.json | def destroy
@booking_tour.destroy
respond_to do |format|
format.html { redirect_to booking_tours_url, notice: 'Booking tour was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tour_booking.destroy\n respond_to do |format|\n format.html { redirect_to tour_bookings_url, notice: 'Tour booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html {... | [
"0.7720043",
"0.7508842",
"0.7508842",
"0.75019956",
"0.7438015",
"0.7422214",
"0.7407837",
"0.74029285",
"0.7401581",
"0.7401581",
"0.7401581",
"0.7401581",
"0.7392334",
"0.7372454",
"0.72857356",
"0.7258151",
"0.7254822",
"0.7254383",
"0.7254383",
"0.7254383",
"0.7254383",
... | 0.7727149 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_booking_tour
@booking_tour = BookingTour.find(params[:id])
# @my_bookings = BookingTour.find(:all, conditions => {:user_id => current_user.id})
@tour = Tour.find(@booking_tour.tour_id)
@user = User.find(@booking_tour.user_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 booking_tour_params
params.require(:booking_tour).permit(:user_id, :tour_id, :number_of_people, :vehicle)
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 |
Original ideas are from the Pinterest sharding blog post: | def shard_id
return nil unless persisted?
Stinger::Sharded::Utils.calculate_shard_id_from(client_id, id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def sitemaps; end",
"def extra_pubish_tasks(p)\n \n end",
"def probers; end",
"def sharing \n end",
"def spouse; end",
"def shard; end",
"def permalink_style; end",
"def post_squares\n\ttumblr()\n\ttweet()\nend",
"def permalink; end",
"def permalink; end",
"def sitema... | [
"0.55907947",
"0.5410634",
"0.5395125",
"0.5309598",
"0.5225481",
"0.5223452",
"0.51930684",
"0.5179948",
"0.5123283",
"0.508204",
"0.508204",
"0.50796705",
"0.50747347",
"0.5031891",
"0.50206286",
"0.50136125",
"0.50069314",
"0.49966723",
"0.49904087",
"0.4979701",
"0.497874... | 0.0 | -1 |
Responds with a feed summarising what has been happening on Blavel recently. Parameters:: everybody Route:: GET /feed/everybody or GET / | def feed
# If the user is not logged in, render the non-member home action
if !current_user
render :template => 'promo/home', :layout => 'empty'
else
@everybody = params[:everybody]
# If the everybody flag is set, respond with feed items about everybody
# on Blavel
# Otherwise, respond with feed items only about the people that the
# current user is following
if @everybody
@feed_items = gather_feed_items
else
@feed_items = gather_feed_items(current_user)
end
# Pass through the first 5 followers and the first 5 followees, all
# randomised
@followers = current_user.followers.sort_by { rand }.first(6)
@followees = current_user.followees.sort_by { rand }.first(6)
# Respond with html or javascript, depending on whether it is requested
# via ajax or not
respond_to do |format|
format.html
format.js { render :template => 'feeds/feed.js.erb', :layout => false }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rss\n\n # Get the specified user, making sure that it exists\n if !@user = User.find_by_login(params[:user_login])\n raise ActiveRecord::RecordNotFound\n end\n\n # If the everybody flag is set, respond with feed items about everybody\n # on Blavel\n # Otherwise, respond with feed items o... | [
"0.6771904",
"0.6584737",
"0.6433012",
"0.64216465",
"0.641569",
"0.6402282",
"0.6347387",
"0.63444835",
"0.62742895",
"0.62711406",
"0.6259243",
"0.61857957",
"0.6183291",
"0.6161313",
"0.61481607",
"0.6098315",
"0.6058668",
"0.60156745",
"0.6004661",
"0.5992061",
"0.5973956... | 0.73251134 | 0 |
Responds with an RSS feed summarising what has been happening on Blavel recently. Parameters:: user_login, everybody Route:: GET /:user_login/feed | def rss
# Get the specified user, making sure that it exists
if !@user = User.find_by_login(params[:user_login])
raise ActiveRecord::RecordNotFound
end
# If the everybody flag is set, respond with feed items about everybody
# on Blavel
# Otherwise, respond with feed items only about the people that the
# current user is following
@everybody = params[:everybody]
if @everybody
@feed_items = gather_feed_items
else
@feed_items = gather_feed_items(current_user)
end
rescue ActiveRecord::RecordNotFound => error
logger.info error
flash[:notice] = 'The user you requested does not exist.'
redirect_to '/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed\n get '/users/self/feed', auth_params\n end",
"def newsfeed\n check_auth :newsfeed\n \n response = connection.post do |req|\n req.url '/user/newsfeed'\n req.body = { :format => @format }\n end\n response\n end",
"def feed\n\n # If the user is no... | [
"0.7430607",
"0.73258257",
"0.7184785",
"0.6987977",
"0.69465137",
"0.68156934",
"0.6808813",
"0.6795361",
"0.6777236",
"0.6725853",
"0.6668379",
"0.6661176",
"0.6636824",
"0.6610064",
"0.65650886",
"0.65381676",
"0.6523088",
"0.65117896",
"0.65061224",
"0.6505545",
"0.649936... | 0.83902174 | 0 |
Collects notes, posts and followings of interest to the specified user, based on the list of users that the specified user is following. | def gather_feed_items(user = nil)
if user
# Notes left on your posts and pictures
notes_on_your_posts = []
user.posts.each do |post|
notes_on_your_posts = smush(notes_on_your_posts, post.notes)
post.pictures.each do |picture|
notes_on_your_posts = smush(notes_on_your_posts, picture.notes)
end
end
# Notes left by people the current user is following
notes_left_by_followees = []
# Notes left on posts owned by people the current user is following
notes_left_on_followees_posts = []
# Notes left on pictures owned by people the current user is following
notes_left_on_followees_pictures = []
# Posts created by people the current user is following
posts_by_followees = []
# Followings of people the current user is following
following_followees = []
# People the current user is following, following other people
followees_following = []
user.followees.each do |followee|
posts_by_followees = smush(posts_by_followees, followee.posts)
notes_left_by_followees = smush(notes_left_by_followees, followee.notes)
followee.posts.each do |post|
notes_left_on_followees_posts = smush(notes_left_on_followees_posts, post.notes)
post.pictures.each do |picture|
notes_left_on_followees_pictures = smush(notes_left_on_followees_pictures, picture.notes)
end
end
following_followees = smush(following_followees, Follow.find_all_by_followee_id(followee.id, :conditions => "follower_id <> #{user.id}"))
followees_following = smush(followees_following, Follow.find_all_by_follower_id(followee.id, :conditions => "follower_id <> #{user.id}"))
end
# Remove totally blank posts from feed
posts_by_followees.each do |post|
if post.title.blank? and post.content.blank? and post.pictures.length == 0
posts_by_followees.delete(post)
end
end
blavel_posts = User.find_by_login('blavel') ? User.find_by_login('blavel').posts : nil
posts = smush(posts_by_followees, blavel_posts)
if posts
posts = posts.uniq
end
# Remove notes left by logged in user
notes = smush(notes_on_your_posts, notes_left_by_followees, notes_left_on_followees_posts, notes_left_on_followees_pictures)
notes.each do |note|
if note.user == user
notes.delete(note)
end
end
notes = notes.uniq
# Add together follows
following_you = Follow.find_all_by_followee_id(user.id)
follows = smush(following_you, following_followees, followees_following)
follows = follows.uniq
else
# If no user is specified, return all feed items
notes = Note.find(:all)
posts = Post.find(:all)
follows = Follow.find(:all)
# Remove totally blank posts from feed
posts.each do |post|
if post.title.blank? and post.content.blank? and post.pictures.length == 0
posts.delete(post)
end
end
end
feed_items = smush(notes, posts, follows)
feed_items.sort! { |x,y| y.created_at <=> x.created_at }
feed_items = feed_items[0..19]
return feed_items
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_posts_by_following\n self.following.collect do |followed|\n followed.get_user_posts\n end\n end",
"def followings_who_reposted(user)\n following_ids = \"SELECT followed_id FROM relationships\n WHERE follower_id = :user_id\"\n repost_ids = \"SELECT user_id FROM r... | [
"0.66495985",
"0.6601784",
"0.65935993",
"0.6557872",
"0.6513237",
"0.6489891",
"0.6462243",
"0.6384748",
"0.6384748",
"0.6384748",
"0.6384748",
"0.6384748",
"0.6384748",
"0.63833135",
"0.6382955",
"0.6356518",
"0.6345423",
"0.63440514",
"0.63076025",
"0.63038784",
"0.6239354... | 0.6669898 | 0 |
Logic to do the Serbea content conversion. | def convert(content, convertible)
return content if convertible.data[:template_engine].to_s != "serbea"
serb_view = Bridgetown::SerbeaView.new(convertible)
serb_renderer = Tilt::SerbeaTemplate.new(convertible.path) { content }
if convertible.is_a?(Bridgetown::Layout)
serb_renderer.render(serb_view) do
convertible.current_document_output
end
else
serb_renderer.render(serb_view)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(content); end",
"def convert(content); end",
"def convert(content)\n content\n end",
"def convert_encoding(content); end",
"def transform\n self.output = converter.convert(self.content)\n end",
"def convert\n end",
"def convert\n end",
"def convert(content, conve... | [
"0.76085526",
"0.76085526",
"0.6679949",
"0.6548518",
"0.6500136",
"0.6409953",
"0.6409953",
"0.62010676",
"0.62005144",
"0.6000762",
"0.5934672",
"0.5866704",
"0.5853359",
"0.58373624",
"0.58219415",
"0.5784155",
"0.57585126",
"0.57382053",
"0.57382053",
"0.57382053",
"0.572... | 0.6687939 | 2 |
GET /docs/1 GET /docs/1.xml | def show
@doc = Doc.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @doc }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @docs = Doc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @docs }\n end\n end",
"def index\n @documentations = Documentation.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :... | [
"0.73454726",
"0.6982665",
"0.6976493",
"0.6911543",
"0.6904562",
"0.688993",
"0.688979",
"0.66943115",
"0.6685996",
"0.6603677",
"0.6537543",
"0.6513314",
"0.6501534",
"0.6482451",
"0.6468345",
"0.6467412",
"0.6467293",
"0.643264",
"0.64263403",
"0.641952",
"0.641499",
"0.... | 0.68268925 | 8 |
GET /docs/new GET /docs/new.xml | def new
@doc = Doc.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @doc }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @tdoc = Tdoc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tdoc }\n end\n end",
"def new\n @documentation = Documentation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documen... | [
"0.7378266",
"0.73517674",
"0.73252195",
"0.7315229",
"0.73115",
"0.7302526",
"0.7254963",
"0.71286243",
"0.71275324",
"0.70804566",
"0.70705295",
"0.6963107",
"0.69150186",
"0.6911079",
"0.69071203",
"0.6817285",
"0.67722136",
"0.6767574",
"0.6731509",
"0.6727882",
"0.672651... | 0.76380885 | 0 |
POST /docs POST /docs.xml | def create
@doc = Doc.new(params[:doc])
respond_to do |format|
if @doc.save
save_object_relationship
format.html { redirect_to(@doc, :notice => 'Doc was successfully created.') }
format.xml { render :xml => @doc, :status => :created, :location => @doc }
else
format.html { render :action => "new" }
format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".x... | [
"0.72255415",
"0.69308174",
"0.68725294",
"0.6734816",
"0.6687378",
"0.6622471",
"0.6555408",
"0.6531164",
"0.63429826",
"0.63218117",
"0.62255645",
"0.61715496",
"0.6109518",
"0.6066895",
"0.60663134",
"0.6059903",
"0.60576105",
"0.6051622",
"0.601317",
"0.60018414",
"0.5992... | 0.6372228 | 8 |
PUT /docs/1 PUT /docs/1.xml | def update
@doc = Doc.find(params[:id])
respond_to do |format|
if @doc.update_attributes(params[:doc])
save_object_relationship
format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n replace_entry \"word/document.xml\", doc.serialize(:save_with => 0)\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc... | [
"0.6696207",
"0.6683047",
"0.6511411",
"0.6509561",
"0.6476924",
"0.64690876",
"0.6467435",
"0.6446949",
"0.64290744",
"0.63760024",
"0.6338613",
"0.62437785",
"0.6197762",
"0.61819047",
"0.6160856",
"0.61603934",
"0.6144149",
"0.61169857",
"0.6080752",
"0.6012608",
"0.601023... | 0.6226837 | 12 |
DELETE /docs/1 DELETE /docs/1.xml | def destroy
@doc = Doc.find(params[:id])
@doc.destroy
respond_to do |format|
format.html { redirect_to(docs_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end",
"def delete\n @client.delete_document(@path)\n end",
"def destroy\n \t@doc = Doc.find params[:id]\n @doc.destroy\nend",
"def de... | [
"0.72869444",
"0.72755927",
"0.7217182",
"0.72114044",
"0.7199847",
"0.7164834",
"0.71060663",
"0.7086409",
"0.7064387",
"0.7062594",
"0.7055722",
"0.70510936",
"0.7034747",
"0.7017842",
"0.7017842",
"0.7017842",
"0.698353",
"0.69778854",
"0.6917641",
"0.6855707",
"0.68376684... | 0.7597995 | 1 |
GET /feedbacks GET /feedbacks.json | def getDashboardHeading
# get hostname or ip adress
ipaddress=server_ipaddress()
@baseurl = "http://" + ipaddress +"/dashboard"
business_id = session[:user_id]
# Fetch Login_ID to use in dashboard heading.
businessrecord = Business.find(business_id)
@login_name=businessrecord.login_id
branch_detail = Branch.where ("business_id='#{business_id}'")
# get all cities in table corresponding to the Business_Id for dropdown
@cityname = branch_detail.map{|t| t.city}.uniq
@cityname.insert(0,"City")
# populate all branches to query for initial dashboard without City and Store selection
branch_list =[]
branch_detail.each do |branchrecord|
branch_list << branchrecord.id
end
if params[:city]
session[:city_id]= params[:city]
end
if params[:store]
session[:store_id]= params[:store]
end
# Initialize the array so that the comboworks on reload
# if params[:city] and params[:city]!="City"
if session[:city_id]!="City"
#session[:city_id]= params[:city]
@cityname.delete("City")
@cityname.delete(session[:city_id])
@cityname.insert( 0, session[:city_id] )
end
# Get all store list in case City has been selected by user
@storename=[]
branchcitywise =[]
singlestorebranch_id =0
if session[:city_id] != "City"
branch_detail.each do |branchrecord|
if branchrecord.city == session[:city_id]
@storename << branchrecord.address_lane2
branchcitywise << branchrecord.id
if branchrecord.address_lane2 == session[:store_id]
singlestorebranch_id= branchrecord.id
end
end
end
@storename.insert(0,"Store") # Initialize the dropdown with Store value at start so that Jquery Combox works
else
@storename << "Store" # Initialize the dropdown with Store value
end
# Initialize the array so that the comboworks on reload
if session[:store_id] !="Store"
#session[:store_id]= params[:store]
deletesucess=@storename.delete(session[:store_id])
if deletesucess
@storename.insert( 0, session[:store_id])
end
@storename.delete("Store")
@storename.compact!
end
#Initialize score or read it from the get URL encoded form.
if params[:fromdate] and params[:todate]
session[:fromdate]=params[:fromdate]
session[:todate] =params[:todate]
end
@fromdate = Date.strptime(session[:fromdate], '%d-%m-%Y')
#lastmonth = DateTime.now - 1.month
@todate = Date.strptime(session[:todate], '%d-%m-%Y')
@branchlistquery = []
if session[:city_id]=="City" and session[:store_id]=="Store"
@branchlistquery =branch_list
elsif session[:city_id]!="City" and session[:store_id]=="Store"
@branchlistquery=branchcitywise
else
@branchlistquery << singlestorebranch_id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @feedbacks = Feedback.find(params[:id])\n render json: @feedbacks\n end",
"def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end",
"def index\n @feedbacks = Feedback.all\n ... | [
"0.7826549",
"0.77483714",
"0.729931",
"0.7205469",
"0.7205469",
"0.7205469",
"0.7205469",
"0.7205469",
"0.7205469",
"0.7205469",
"0.7205469",
"0.7204222",
"0.71323884",
"0.71269554",
"0.71092725",
"0.71042246",
"0.7046424",
"0.6971945",
"0.69489086",
"0.69489086",
"0.6948908... | 0.0 | -1 |
Function to Initialize PieChart details . | def getPieChartDetails
# Query the Table to perform the average netscore calcuations based on selections in combobox
sentimentarray=[1,2]
@piechartPositive =Feedback.count(:all, :conditions => ["created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray])
sentimentarray=[4,5]
@piechartNegative =Feedback.count(:all, :conditions => ["created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray])
sentimentarray=[3]
@piechartNeutral =Feedback.count(:all, :conditions => ["created_at >= ? and created_at <= ? and branch_id IN (?) and sentiment_id IN (?)",@fromdate.beginning_of_day,@todate.end_of_day,@branchlistquery,sentimentarray])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb... | [
"0.69168645",
"0.69153965",
"0.6834023",
"0.6832453",
"0.6568081",
"0.6499712",
"0.6489237",
"0.6483504",
"0.6473609",
"0.64632523",
"0.6460507",
"0.6399721",
"0.63776857",
"0.6352853",
"0.63277155",
"0.6327049",
"0.6301558",
"0.61803705",
"0.6153249",
"0.6087581",
"0.6043200... | 0.6085994 | 20 |
== Description Marks ==Resource URL /notifications/mark_as_read.format ==Example GET === Parameters [access_token] | def mark_as_read
if Notification.mark_as_read
return_message(200, :ok)
else
return_message(200, :fail)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end",
"def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification... | [
"0.8051977",
"0.76122284",
"0.7424262",
"0.7302608",
"0.72733927",
"0.7167887",
"0.6897111",
"0.6792239",
"0.6751037",
"0.6677822",
"0.6609783",
"0.6590586",
"0.65806997",
"0.6579009",
"0.65284127",
"0.65170896",
"0.6486224",
"0.64611566",
"0.64569694",
"0.64274645",
"0.64183... | 0.75957525 | 2 |
Riddle me this for some reason newlines aren't being counted correctly. TODO: find out WTF and fix it better than this | def fix_length response
size = 0
response.body.each {|str| size += str.scan(/\n/).size}
size += response.headers['Content-Length'].to_i
response.headers['Content-Length'] = size.to_s
return response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_paragraphs(some_file)\n file_content = open(some_file).read()\n count = 0\n file_content_split = file_content.split('')\n\n file_content_split.each_index do |index|\n count += 1 if file_content_split[index] == \"\\n\" && file_content_split[index + 1] == \"\\n\"\n end\n return count\nend",
"def... | [
"0.71168685",
"0.71083516",
"0.7004993",
"0.6898843",
"0.68573344",
"0.6828885",
"0.6800682",
"0.6671742",
"0.6671742",
"0.6571755",
"0.6557376",
"0.6517456",
"0.6482509",
"0.64721555",
"0.64659965",
"0.64512116",
"0.644085",
"0.6413042",
"0.6355668",
"0.6347384",
"0.6345361"... | 0.0 | -1 |
Helper so we fail as soon as a command fails. | def try(command)
system command
if $? != 0 then
raise "Command: `#{command}` exited with code #{$?.exitstatus}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fails?(command)\n !succeeds?(command)\n end",
"def test_command_failed\n assert_raise(Report::CommandFailed) { @report.run('nosuch') }\n assert_raise(Report::CommandFailed) { @report.run('cat', 'nosuch') }\n end",
"def systemOrDie(*cmd)\n puts 'executes: ' + cmd.join(' ')\n ret = syste... | [
"0.7749971",
"0.7313537",
"0.72639406",
"0.7169728",
"0.7165012",
"0.71015656",
"0.71015656",
"0.70755875",
"0.70400465",
"0.7017292",
"0.7017292",
"0.6931168",
"0.68997175",
"0.6884572",
"0.68222016",
"0.6814395",
"0.6744312",
"0.6707489",
"0.665084",
"0.665084",
"0.66241837... | 0.72440755 | 5 |
Provides an easy way to safely get a new instance of the change set persister with different initialization parameters. If passed a block it will yield the new adapter. | def with(metadata_adapter: self.metadata_adapter, storage_adapter: self.storage_adapter)
new_adapter = self.class.new(metadata_adapter: metadata_adapter, storage_adapter: storage_adapter, transaction: true, characterize: @characterize, queue: queue, handlers: handlers)
return new_adapter unless block_given?
yield new_adapter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_set_persister\n @change_set_persister ||= ChangeSetPersister.new(\n metadata_adapter: metadata_adapter,\n storage_adapter: storage_adapter\n )\n end",
"def change_set_persister\n ChangeSetPersister.new(\n metadata_adapter: Valkyrie::MetadataAdapter.find(:indexing_per... | [
"0.6424072",
"0.61457366",
"0.6041625",
"0.5727419",
"0.57272786",
"0.57213545",
"0.5609853",
"0.5563403",
"0.5532884",
"0.55009294",
"0.548743",
"0.5486624",
"0.5486624",
"0.546452",
"0.5454907",
"0.5445493",
"0.5434343",
"0.54263735",
"0.5423923",
"0.5423426",
"0.5423426",
... | 0.5819403 | 3 |
GET /news_topics GET /news_topics.json | def index
@news_main_topics = NewsTopic.includes(:creator).order('id DESC').limit(10)
@top_news = NewsTopic.top_news.order('id DESC').limit(10)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topics\n client = Comments.discourse\n @topics = client.latest_topics\n respond_to do |fmt|\n fmt.js { }\n end\n end",
"def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end",
"def index\n @topics = Topic.getCommunityTopic(params)\n respo... | [
"0.74555147",
"0.74209386",
"0.71408075",
"0.7062938",
"0.7062938",
"0.7062938",
"0.6920321",
"0.6891208",
"0.6880907",
"0.6807371",
"0.6807371",
"0.6802782",
"0.6796547",
"0.67363703",
"0.6723964",
"0.6695416",
"0.66777205",
"0.66697466",
"0.66660213",
"0.66615915",
"0.66600... | 0.6232536 | 86 |
POST /news_topics POST /news_topics.json | def create
@news_topic = NewsTopic.new(news_topic_params)
@news_topic.context.gsub!("\n", '</br>')
@news_topic.short_context.gsub!("\n", '</br>')
@news_topic.creator = current_user
respond_to do |format|
if @news_topic.save
format.html { redirect_to news_topics_path, :notice => 'News topic was successfully created.' }
format.json { render :show, :status => :created, :location => @news_topic }
else
format.html { render :new }
format.json { render :json => @news_topic.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateTopic params = {}\n \n APICall(path: 'topics.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Top... | [
"0.7357698",
"0.6798283",
"0.6776125",
"0.67456883",
"0.6699255",
"0.6676694",
"0.6672996",
"0.6671501",
"0.66629356",
"0.66322255",
"0.66322255",
"0.65982664",
"0.659068",
"0.6583488",
"0.6552721",
"0.65452695",
"0.65414506",
"0.65412253",
"0.6539774",
"0.6532048",
"0.652189... | 0.70594347 | 1 |
PATCH/PUT /news_topics/1 PATCH/PUT /news_topics/1.json | def update
news_topic_params[:context].gsub!("\n", '</br>')
news_topic_params[:short_context].gsub!("\n", '</br>')
respond_to do |format|
if @news_topic.update(news_topic_params)
format.html { redirect_to news_topics_path, :notice => 'News topic was successfully updated.' }
format.json { render :show, :status => :ok, :location => @news_topic }
else
format.html { render :edit }
format.json { render :json => @news_topic.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateTopic id,params = {}\n \n APICall(path: \"topics/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @topic.update_attributes!(topic_params)\n json_response(@topic)\n end",
"def update\n topic = Topic.find(params[:id])\n if topic.upd... | [
"0.70032775",
"0.69635344",
"0.69390434",
"0.67616516",
"0.6709714",
"0.66886914",
"0.66778624",
"0.66565174",
"0.6649291",
"0.6628653",
"0.6588845",
"0.6554845",
"0.6515214",
"0.649727",
"0.6496807",
"0.6495477",
"0.6495477",
"0.6495477",
"0.6495477",
"0.6495477",
"0.648349"... | 0.68710464 | 3 |
DELETE /news_topics/1 DELETE /news_topics/1.json | def destroy
@news_topic.destroy
respond_to do |format|
format.html { redirect_to news_topics_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteTopic id\n \n APICall(path: \"topics/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n Topic.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end",
"def destroy\n @topic.destroy\n\n respond_to do |format|\n format.htm... | [
"0.7404525",
"0.7351225",
"0.73037225",
"0.72831625",
"0.72235703",
"0.72208005",
"0.7214375",
"0.7214375",
"0.7214375",
"0.7214375",
"0.7214375",
"0.7214375",
"0.7207892",
"0.71965367",
"0.7192788",
"0.7188378",
"0.71769315",
"0.71750075",
"0.7173123",
"0.7172821",
"0.717282... | 0.7848001 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_news_topic
@news_topic = NewsTopic.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def news_topic_params
params.require(:news_topic).permit(:title, :context, :short_context, :top_news)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
default to Active Model Serializers | def index
respond_with Biblebook.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serializer; end",
"def active_model_serializer\n self.class.active_model_serializer\n end",
"def active_model_serializer\n self.class.active_model_serializer\n end",
"def active_model_serializer\n self.tire_active_model_serializer || self.class.active_model_serializer\n end",
"d... | [
"0.7626089",
"0.7502072",
"0.7502072",
"0.74956775",
"0.7128708",
"0.71244043",
"0.71244043",
"0.7044808",
"0.7037385",
"0.7022828",
"0.7021476",
"0.69898736",
"0.69813955",
"0.6961405",
"0.695881",
"0.69499123",
"0.69399583",
"0.69399583",
"0.69399583",
"0.69160724",
"0.6913... | 0.0 | -1 |
CanCanCan requires a current_user method. Devise gives us a current_parent method because our user model is "parent". | def current_user
current_parent
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can?\n current_user\n end",
"def current_user? user\n \tuser == self.current_user\n end",
"def current_user\n raise NotImplementedError\n end",
"def current_user\n raise NotImplementedError\n end",
"def can_access?(user)\n user == self.user\n end",
"def current_user?\n \n en... | [
"0.74109626",
"0.6769095",
"0.6760633",
"0.6760633",
"0.6671004",
"0.66665196",
"0.66421807",
"0.66421807",
"0.6547788",
"0.6526454",
"0.6463764",
"0.6446514",
"0.6431798",
"0.6417328",
"0.63825953",
"0.63825953",
"0.63825953",
"0.63825953",
"0.6370018",
"0.63592565",
"0.6350... | 0.7049864 | 1 |
def fast_dance(target, array) i = 0 until i == array.length return i if array[i] == target i += 1 end end def tiles_array_to_hash(array) tiles = Hash.new array.each_with_index do |tile, index| tiles[tile] = index end tiles end | def tiles_array_to_hash(array)
tiles = Hash.new
i = 0
until i == array.length
tiles[array[i]] = i
i += 1
end
tiles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slow_dance(target, tiles_array)\n tiles_array.each_with_index do |tile, idx|\n return idx if tile == target\n end\nend",
"def slow_dance(target_tile, tiles_array)\n tiles_array.each_with_index do |tile, index|\n return index if target_tile == tile\n end\n\n nil\nend",
"def slow_dance(tile, tiles... | [
"0.7861287",
"0.77635753",
"0.75977266",
"0.7586032",
"0.7337834",
"0.7315145",
"0.7287052",
"0.72731376",
"0.72502065",
"0.72376174",
"0.7206896",
"0.7113757",
"0.7110152",
"0.7090259",
"0.7063407",
"0.70596355",
"0.7054865",
"0.705089",
"0.7046278",
"0.7044824",
"0.7025681"... | 0.83233476 | 0 |
I worked on this challenge with Brian Wagner. I spent 1 hour on this challenge. Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. =begin 0. Pseudocode What is the input? An array, an integer (>minimum size of the new array), OPTIONAL argument for new content What is the output? (i.e. What should the code return?) New array of the new size OPTIONAL w/ the specified content What are the steps needed to solve the problem? test size of the array IF size is min array then RETURN ELSE OPTIONAL FOR PAD > create a new variable to store the new array IF an element is specified, then padded element = that element push items to array until it meets the min. size ELSE push nil to array END IF END IF =end 1. Initial Solution | def pad!(array, min_size, value = nil) #destructive
if array.length >= min_size
return array
else
loop do array.push(value)
break if array.length >= min_size
end
p array
return array
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad!(array, min_size, value = nil) #destructive\n if array.length >= min_size\n return array\n end\n if min_size > array.length\n remainder = min_size - array.length\n remainder.times do array << value\n end\n end\n p array\nend",
"def pad!(array, min_size, value = nil) #destructive\n solut... | [
"0.83708715",
"0.83378047",
"0.8288198",
"0.8265814",
"0.82154775",
"0.8205737",
"0.8202612",
"0.81957716",
"0.8183907",
"0.8183643",
"0.8180579",
"0.8177256",
"0.8177032",
"0.8170709",
"0.8166718",
"0.8157134",
"0.8150498",
"0.8149299",
"0.81483346",
"0.8144131",
"0.8142917"... | 0.8226026 | 4 |
either 3 or 4 gram | def initialize (type)
@type = type
if @type == 3
@@types = ["#{@@config.get_value('correct_tables')}_3grams"] # The tables we wish to query (no h table)
elsif @type == 4
@@types = "#{@@config.get_value('correct_tables')}_4grams" # The tables we wish to query (no h table)
end
@database = @@config.get_value('mysql_database')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grams\n gram_equivalent / amount\n end",
"def gram? = unit == 'gram'",
"def gram_schmidtR\n gram_schmidt[1]\n end",
"def dynamic_phrase_4\r\n\r\n # Verse 1: **no more bottles**\r\n if one_bottle?\r\n \"no more bottles\"\r\n # Verse 0: **99 bottles**\r\n elsif zero_bottles?\r\n ... | [
"0.675764",
"0.6333547",
"0.62891024",
"0.61426634",
"0.6099826",
"0.5895995",
"0.58596414",
"0.57853615",
"0.57394326",
"0.5702608",
"0.5698234",
"0.56842625",
"0.56842625",
"0.5603044",
"0.554378",
"0.550506",
"0.5471493",
"0.547122",
"0.543313",
"0.54058",
"0.53909135",
... | 0.0 | -1 |
Example: Given s = "hello", return "olleh". With Stack DS Reversal is the convenient propery of a stack Time: O(n) Space: O(n) | def reverse_string(s)
i = 0
stack = []
while i < s.length do
stack.push(s[i])
i += 1
end
rev_s = ""
while stack.length > 0 do
rev_s = stack.pop
end
rev_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_string(string)\n #time complexity and space compexity O(n), there are 2 loops but they are not nested\n #each loop is O(n)\n return nil if string.class != String #check if input os correct\n local_stack = Stack.new() #create new Stack instance\n string.each_char do |char| #insert all character fro... | [
"0.77927005",
"0.7500197",
"0.7455506",
"0.74365205",
"0.7389628",
"0.7383772",
"0.73691225",
"0.73644763",
"0.7344535",
"0.7344316",
"0.73431414",
"0.73221034",
"0.73095644",
"0.7288908",
"0.72886795",
"0.72840345",
"0.72802263",
"0.72776836",
"0.72693324",
"0.7268374",
"0.7... | 0.74932414 | 2 |
allows us to repeat code in an efficient and elegant way def repeatHello() puts "hello" puts "hello" puts "hello" end repeatHello() | def repeatHello()
counter = 1
while counter <= 5
puts "hello"
counter += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeatHello(n)\n i = 0\n while i < n\n puts 'hello'\n i += 1\n end\nend",
"def say_hello_world_five_times\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\n puts \"Hello World!\"\nend",
"def repeat_hi(num)\n num.times { puts \"hi\" }\nend",
... | [
"0.79736364",
"0.7934241",
"0.7758329",
"0.767839",
"0.7601328",
"0.7591109",
"0.7579973",
"0.75767684",
"0.7562978",
"0.7514474",
"0.74113965",
"0.7374898",
"0.7361804",
"0.73304784",
"0.7329748",
"0.7329748",
"0.7329748",
"0.7329748",
"0.7286418",
"0.72671235",
"0.7205633",... | 0.808041 | 0 |
while loops in ruby while the condition of a loop is true, keep running the loop once the condition is false, stop the loop | def printNums
i = 10
while i >= 0
puts i
i -= 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def while(&block)\n\t\t\t\t\trepeat &block\n\t\t\t\tend",
"def while(&blk)\n loop{ !blk[] }\n end",
"def endless_loop?; end",
"def loop_while(options={}, &block)\n timeout = options.delete(:timeout) || 2500\n timeout = 10 if timeout < 10\n\n result = block_given? ? block.call : true\n ... | [
"0.76866835",
"0.74159867",
"0.73592836",
"0.7293499",
"0.70555836",
"0.7024165",
"0.7012738",
"0.70073515",
"0.6984371",
"0.6954088",
"0.6946046",
"0.6941181",
"0.69066024",
"0.6900002",
"0.6895594",
"0.6893903",
"0.6810378",
"0.6783853",
"0.67562807",
"0.6650762",
"0.662881... | 0.0 | -1 |
next skips over lines after the keyword which may give us an infinite loop | def count_e(word)
count = 0 #use count to track number of e's
i = 0 #use i to iterate thru the word
while i < word.length
char = word[i]
if char == "e"
count += 1
end
i += 1
end
return count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next\n\t\tlines.shift\n\tend",
"def next_line\r\n while true\r\n if (@lexemes[@pointer] != nil && @lexemes[@pointer] != '@')\r\n @pointer = @pointer.next\r\n else\r\n break\r\n end\r\n end\r\n end",
"def next() end",
"def next() end",
"def next!() end",
"def next()... | [
"0.73528796",
"0.70547456",
"0.69377375",
"0.69377375",
"0.6892023",
"0.6636262",
"0.6636262",
"0.6536763",
"0.65288407",
"0.65288407",
"0.6528184",
"0.6528184",
"0.641257",
"0.6408983",
"0.63588154",
"0.631785",
"0.63095146",
"0.62650967",
"0.62303585",
"0.61642766",
"0.6164... | 0.0 | -1 |
Write a method count_a(word) that takes in a string word and returns the number of a's in the word. The method should count both lowercase (a) and uppercase (A) | def count_a(word)
count = 0
i = 0
while i < word.length
char = word[i]
if char == "a" || char == "A"
count += 1
end
i += 1
end
return count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_a(word)\n\tcounter = 0\n \ti = 0\n \twhile i < word.length\n if word[i] == \"a\" || word[i] == \"A\"\n counter += 1\n end\n i += 1\n end\n return counter\nend",
"def count_a(word)\n counter = 0\n i = 0\n while i < word.length\n if word[i] == 'a' || word[i] == 'A'\n ... | [
"0.8507787",
"0.83433735",
"0.8239746",
"0.82122564",
"0.8187825",
"0.8124194",
"0.8091351",
"0.77053815",
"0.76894563",
"0.76484746",
"0.75016713",
"0.7400636",
"0.7376295",
"0.7376295",
"0.73643357",
"0.72911525",
"0.7268074",
"0.72583455",
"0.7255492",
"0.72534347",
"0.725... | 0.81031877 | 6 |
15 Write a method factorial(num) that takes in a number num and returns the product of all numbers from 1 up to and including num. | def factorial(num)
product = 1
i = 1
while i <= num
product *= i #shorthand for product = product * i
i += 1
end
return product
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factorial(num)\n product = num\n (1...num).each{|n| product *= n}\n product\nend",
"def factorial(num)\n product = 1\n for factor in 1..num\n product *= factor\n end\n product\nend",
"def factorial(num)\n\t(1..num).reduce(1,:*) \nend",
"def factorial(num)\n\tproduct = 1\n\twhile num > 1\n\t\tpr... | [
"0.8604505",
"0.8512827",
"0.84923476",
"0.84742993",
"0.8452763",
"0.84388113",
"0.8429415",
"0.84178513",
"0.8382182",
"0.8377633",
"0.83741176",
"0.83719283",
"0.8366873",
"0.8364962",
"0.83632004",
"0.83593404",
"0.83456445",
"0.83437365",
"0.83410496",
"0.83222485",
"0.8... | 0.8215293 | 32 |
Write a method reverse(word) that takes in a string word and returns the word with its letters in reverse order. | def reverse(word)
reversed_str = ""
i = 0
while i < word.length
char = word[i]
reversed_str += char
i += 1
end
return reversed_str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_string word\n\t\treturn word.reverse\nend",
"def reverse_word(word)\n return word.reverse\n end",
"def rev(word)\n word.reverse\nend",
"def reverse(word) # defines the method with one param\n\ti = 0 # sets value at zero\n\trevered_string = \"\" # creates empty string to put reversed ... | [
"0.8523614",
"0.85053015",
"0.8354318",
"0.8330286",
"0.8022159",
"0.7969943",
"0.7950174",
"0.79459924",
"0.793259",
"0.7910705",
"0.790938",
"0.7905664",
"0.78725773",
"0.7862317",
"0.7856957",
"0.7854052",
"0.7822807",
"0.78175557",
"0.7801047",
"0.7794002",
"0.77935696",
... | 0.77328753 | 24 |
Write a method is_palindrome(word) that takes in a string word and returns the true if the word is a palindrome, false otherwise. A palindrome is a word that is spelled the same forwards and backwards. | def is_palindrome(word)
reversed = ""
i = 0
while i < word.length
reversed = word[i] + reversed
i += 1
end
if word == reversed
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_palindrome?(word)\n if word == word.reverse\n return true\n else\n return false\n end\nend",
"def palindrome_word?(word)\n word.downcase === word.downcase.reverse ? true : false\n end",
"def palindrome?\n formatted_word = @word.gsub(/[^a-z]/, \"\")\n formatted_word == formatted_word.r... | [
"0.9020713",
"0.89196897",
"0.88044435",
"0.8780252",
"0.8775502",
"0.87751156",
"0.8764665",
"0.8759603",
"0.87477624",
"0.8715222",
"0.8701719",
"0.8692352",
"0.8687892",
"0.86864626",
"0.8669412",
"0.86614144",
"0.8647115",
"0.8644766",
"0.8634355",
"0.8629967",
"0.8624174... | 0.8319942 | 35 |
Only allow a trusted parameter "white list" through. | def setting_params
params.require(:setting).permit(:company_id, :email_domain, :email_username, :email_password, :year_start)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
When the source is executed, is the stack as expected? Parameters: source A string containing fOOrth source code to execute. remainder An array with the expected stack contents after execution. debug Set to true to display debug info. | def foorth_equal(source, remainder=[], debug=false)
self.assertions += 1
vm = Thread.current[:vm]
vm.debug = debug
vm.process_string(source)
unless remainder == vm.data_stack
msg = "Expected: #{remainder.inspect}\n Actual: #{vm.data_stack.inspect}"
raise MiniTest::Assertion, msg, caller
end
ensure
vm.debug = false
vm.interpreter_reset
vm.compiler_reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_stack_050\n\n @vc.parse <<EOF\n\n: test\n\n 0. 2dup 1+\n 2dup 1+\n 2dup 1+\n\n;\n\nEOF\n @vc.compile\n @vc.run\n assert_equal(:halt, @vc.vm.state)\n assert_equal(8, @vc.vm.depth)\n assert_equal(3, @vc.vm.tos)\n assert_equal(0, @vc.vm.nos)\n assert_equal(2, @vc.vm.pick(2))\... | [
"0.56363285",
"0.55064595",
"0.5483121",
"0.54107827",
"0.53877676",
"0.5355571",
"0.5336258",
"0.5324759",
"0.53176534",
"0.5309316",
"0.5291421",
"0.52229327",
"0.5220815",
"0.5201189",
"0.5191559",
"0.5163625",
"0.5132058",
"0.5120024",
"0.509449",
"0.5086987",
"0.5086938"... | 0.6517152 | 0 |
When the source is executed, does it raise err? Parameters: source A string containing fOOrth source code to execute. err The type of exception expected during execution. debug Set to true to display debug info. | def foorth_raises(source, err=XfOOrth::XfOOrthError, debug=false)
self.assertions += 1
vm = Thread.current[:vm]
vm.debug = debug
failed, msg = false, ""
begin
vm.process_string(source)
msg = "Expected: #{err}\n Actual: No exception raised."
failed = true
rescue Exception => e
unless e.class == err
msg = "Expected: #{err}\n Actual: #{e.class}"
failed = true
end
end
raise MiniTest::Assertion, msg, caller if failed
ensure
vm.debug = false
vm.interpreter_reset
vm.compiler_reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_code source\n source.execute(@scope)\n rescue Exception => e\n message, name = @exception_service.get_exception_message(e)\n puts \"#{name}: #{message}\"\n end",
"def handle(source)\n invoke(source) do\n yield\n return true\n end\n rescue SystemExit, Interrupt\n ... | [
"0.658366",
"0.602478",
"0.58708334",
"0.58195186",
"0.573926",
"0.5697565",
"0.563682",
"0.5585326",
"0.5515037",
"0.5498707",
"0.5452647",
"0.5423247",
"0.5377079",
"0.53615063",
"0.5344714",
"0.53347415",
"0.53341156",
"0.5292102",
"0.52579993",
"0.5241385",
"0.5228521",
... | 0.72055614 | 0 |
When the source is executed, does the stdout match? Parameters: source A string containing fOOrth source code to execute. expected A string with the expected console output. | def foorth_output(source, expected)
self.assertions += 1
failed, msg = false, ""
vm = Thread.current[:vm]
actual, _nc = capture_io do
vm.process_string(source)
end
if expected != actual
msg = "Expected: #{expected.inspect}\n Actual: #{actual.inspect}"
raise MiniTest::Assertion, msg, caller
end
ensure
vm.interpreter_reset
vm.compiler_reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foorth_utf8_output(source, expected)\r\n self.assertions += 1\r\n vm = Thread.current[:vm]\r\n\r\n actual = capture_foorth_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.inspect}\"\r\n raise ... | [
"0.70157194",
"0.59723455",
"0.5947456",
"0.5921424",
"0.58899117",
"0.5832348",
"0.5831107",
"0.5817124",
"0.5762262",
"0.57610613",
"0.57472575",
"0.5712533",
"0.56552607",
"0.561581",
"0.5601578",
"0.55762404",
"0.5573613",
"0.5562881",
"0.55486417",
"0.55486107",
"0.55253... | 0.767308 | 0 |
Copied here for study | def capture_foorth_io
require 'stringio'
orig_stdout = $stdout
(s_o = StringIO.new).set_encoding 'UTF-8'
captured_stdout = s_o
$stdout = captured_stdout
yield
return captured_stdout.string.bytes.to_a
ensure
$stdout = orig_stdout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def formation; end",
"def stderrs; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def terpene; end",
"def transformations; end",
"def schumann; end",
"def suivre; end",
"def malts; end",
"de... | [
"0.70659965",
"0.66911554",
"0.64754254",
"0.6433394",
"0.6416257",
"0.61991954",
"0.61991954",
"0.61991954",
"0.61991954",
"0.61891776",
"0.61838746",
"0.61520123",
"0.60844535",
"0.6079408",
"0.60446894",
"0.6017083",
"0.60110307",
"0.60110307",
"0.59987545",
"0.599644",
"0... | 0.0 | -1 |
When the source is executed, does the stdout match? Forces UTF8 encoding. Parameters: source A string containing fOOrth source code to execute. expected An array of bytes expected for the console. | def foorth_utf8_output(source, expected)
self.assertions += 1
vm = Thread.current[:vm]
actual = capture_foorth_io do
vm.process_string(source)
end
if expected != actual
msg = "Expected: #{expected.inspect}\n Actual: #{actual.inspect}"
raise MiniTest::Assertion, msg, caller
end
ensure
vm.interpreter_reset
vm.compiler_reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foorth_output(source, expected)\r\n self.assertions += 1\r\n failed, msg = false, \"\"\r\n vm = Thread.current[:vm]\r\n\r\n actual, _nc = capture_io do\r\n vm.process_string(source)\r\n end\r\n\r\n if expected != actual\r\n msg = \"Expected: #{expected.inspect}\\n Actual: #{actual.... | [
"0.6836297",
"0.57445174",
"0.5527761",
"0.55262053",
"0.5476257",
"0.53938174",
"0.53484714",
"0.52858",
"0.5235409",
"0.52103627",
"0.5196066",
"0.5159371",
"0.51182836",
"0.5092261",
"0.5085589",
"0.5081283",
"0.5078978",
"0.50459325",
"0.50458187",
"0.5039253",
"0.503713"... | 0.79969436 | 0 |
Returns a GitHubV3API instance that is able to access github with the +access_token+ owner's authorization. +access_token+:: an OAuth2 access token from GitHub | def initialize(access_token)
@access_token = access_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def github_client\n Octokit::Client.new access_token: self.setting.user_with_token.client_token\n end",
"def github_client\n Octokit::Client.new(\n access_token: ENV.try(:[], \"GITHUB_ACCESS_TOKEN\"),\n auto_paginate: true\n )\n end",
"def client\n @client ||= Github... | [
"0.7068926",
"0.69696385",
"0.69013715",
"0.6895382",
"0.689267",
"0.6880736",
"0.6839184",
"0.67827535",
"0.6717281",
"0.66003996",
"0.65335095",
"0.649354",
"0.6418895",
"0.64068305",
"0.6366165",
"0.63332725",
"0.62964094",
"0.62964094",
"0.62658346",
"0.6263605",
"0.62228... | 0.0 | -1 |
Entrypoint for access to the GitHub Orgs API Returns an instance of GitHubV3API::OrgsAPI that will use the access_token associated with this instance. | def orgs
OrgsAPI.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end",
"def orgs(org=nil, params={})\n params = org if org.is_a?Hash\n prefix = org.is_a?(String) ? \"./orgs/#{org}\" : \"#{path_prefix}/orgs\"\n Ghee::API::Orgs::Proxy... | [
"0.6337335",
"0.6165816",
"0.61026543",
"0.59596527",
"0.59592384",
"0.5948756",
"0.59453267",
"0.59437686",
"0.5920983",
"0.58958304",
"0.58629733",
"0.58022803",
"0.58022803",
"0.57970595",
"0.57865095",
"0.57851607",
"0.5758082",
"0.5731234",
"0.56852746",
"0.5670283",
"0.... | 0.706001 | 0 |
Entrypoint for access to the GitHub Repos API Returns an instance of GitHubV3API::ReposAPI that will use the access_token associated with this instance. | def repos
ReposAPI.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_api\n @github_api = ::Github::Repos.new do |github_config|\n github_config.endpoint = @endpoint if @endpoint\n github_config.site = @site if @site\n github_config.basic_auth = @auth\n github_config.repo = @repo\n github_config.org = @... | [
"0.6943118",
"0.6608241",
"0.6483988",
"0.64393836",
"0.6400369",
"0.6399662",
"0.6278856",
"0.6278856",
"0.6177636",
"0.61451894",
"0.6114128",
"0.6109095",
"0.60644937",
"0.6063871",
"0.60212547",
"0.5994289",
"0.5990497",
"0.59800434",
"0.59761786",
"0.5965133",
"0.5935123... | 0.72777426 | 0 |
Applies changeset to provider | def apply_changeset(changeset, stdout = $stdout)
begin
stdout.puts "Applying #{changeset.additions.size} additions, #{changeset.removals.size} removals, & #{changeset.updates.size} updates..."
changeset.changes.each do |change|
case change.type
when :removal;
stdout.puts "Removing #{change.record}..."
remove(change.record)
when :addition;
stdout.puts "Creating #{change.record}..."
add(change.record)
when :update;
stdout.puts "Updating record with ID #{change.id} to #{change.record}..."
update(change.id, change.record)
else
raise ArgumentError, "Unknown change type #{change.type.inspect}"
end
end
puts "\nPublished #{@zone_name} changes"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @providers = args[:providers] if args.key?(:providers)\n end",
"def update!(**args)\n @available_providers = args[:available_providers] if args.key?(:available_providers)\n @provider_filter_state = args[:provider_filter_state] if args.key?(:provider_filter_... | [
"0.6142536",
"0.5951969",
"0.57622623",
"0.5752811",
"0.56973803",
"0.5648445",
"0.55884767",
"0.5579915",
"0.55569077",
"0.5551381",
"0.5480244",
"0.54727393",
"0.546864",
"0.5427239",
"0.5379173",
"0.5363861",
"0.53466374",
"0.53225005",
"0.5283321",
"0.526186",
"0.52458304... | 0.49791932 | 56 |
returns an array of Record objects that match the records which exist in the provider | def retrieve_current_records(stdout = $stdout)
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_records(records)\n records.select do |record|\n conditions.matches?(record)\n end\n end",
"def records\n arr = @klass.all(find_options)\n arr.empty? ? nil : arr\n end",
"def get_qual_records\n records = storage_engine.get_all\n qual_records = []\n recor... | [
"0.65471923",
"0.6459398",
"0.63806516",
"0.63690865",
"0.62472486",
"0.62401265",
"0.61961997",
"0.6161258",
"0.6103535",
"0.60991985",
"0.6047942",
"0.6035323",
"0.59883994",
"0.5941563",
"0.59172106",
"0.5853252",
"0.5830838",
"0.57436496",
"0.5725649",
"0.57112825",
"0.57... | 0.0 | -1 |
Returns an array of the zones managed by provider as strings | def zones
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zones\n\t\tself.provider_account.zones\n\tend",
"def zone_names; end",
"def zone_names; end",
"def zone_info\n @info.zones\n end",
"def zone_identifiers\n @info.zone_identifiers\n end",
"def zones\n zone_uris.map{ |u| Zone.find(u) }\n end",
"def zones\n raise_not_implemente... | [
"0.79429805",
"0.75120246",
"0.75120246",
"0.7230447",
"0.7071339",
"0.70540637",
"0.69979024",
"0.699423",
"0.6966636",
"0.69516176",
"0.6862275",
"0.68405527",
"0.6740473",
"0.6736211",
"0.6707684",
"0.6658854",
"0.6658854",
"0.66318566",
"0.6565162",
"0.6564181",
"0.654989... | 0.6860674 | 11 |
Define a method for calculating possible scores given a set of cards | def possible_scores(cards)
scores = [0]
cards.each do |card|
if card.face != 'Ace'
scores.map! {|score| score + card.value}
else
new_scores = Array.new
scores.each do |score|
new_scores << score + 1
new_scores << score + 11
end
scores = new_scores
end
end
return scores.uniq.select {|score| score < 22}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_score (cards)\n\t\tscore = 0\n\t\tcards.each do |card|\n\t\t\tmeasure = card[0]\n\t\t\tscore += @score[measure]\n\t\tend\n\t\tscore\n\tend",
"def score(cards)\n\nend",
"def determine_score(deck)\n total = 0\n deck.each do |suit|\n suit[1].each do |card|\n total += score(card)\n end\n end\... | [
"0.7849427",
"0.7831273",
"0.7678231",
"0.75986767",
"0.7538762",
"0.7537035",
"0.7523754",
"0.7376404",
"0.7370201",
"0.73631305",
"0.732527",
"0.72155845",
"0.71937287",
"0.71263814",
"0.7108032",
"0.7089502",
"0.70260406",
"0.69806904",
"0.69432163",
"0.6935274",
"0.693352... | 0.77857345 | 2 |
GET /weekday_constraints GET /weekday_constraints.json | def index
@weekday_constraints = WeekdayConstraint.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end",
"def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end",
"def create\n @weekday_constraint = WeekdayConstraint.new(weekday_... | [
"0.6874917",
"0.66797906",
"0.6641648",
"0.6457305",
"0.58466655",
"0.56341594",
"0.5632721",
"0.5618513",
"0.52801335",
"0.52129275",
"0.5209437",
"0.52041125",
"0.51893747",
"0.51515067",
"0.5139131",
"0.5136341",
"0.5133472",
"0.50987536",
"0.50879043",
"0.50868165",
"0.50... | 0.76894635 | 0 |
GET /weekday_constraints/1 GET /weekday_constraints/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @weekday_constraints = WeekdayConstraint.all\n end",
"def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end",
"def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end",... | [
"0.75863177",
"0.69366103",
"0.68298185",
"0.682787",
"0.67159635",
"0.5823258",
"0.55903125",
"0.5475184",
"0.5405808",
"0.53683877",
"0.5355628",
"0.53435016",
"0.528457",
"0.5261186",
"0.5205836",
"0.52036566",
"0.52011573",
"0.5085956",
"0.5054797",
"0.5045783",
"0.498519... | 0.0 | -1 |
POST /weekday_constraints POST /weekday_constraints.json | def create
@weekday_constraint = WeekdayConstraint.new(weekday_constraint_params)
respond_to do |format|
if @weekday_constraint.save
format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully created.' }
format.json { render :show, status: :created, location: @weekday_constraint }
else
format.html { render :new }
format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end",
"def index\n @weekday_constraints = WeekdayConstraint.all\n end",
"def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end",... | [
"0.7552138",
"0.7152779",
"0.6963185",
"0.6773598",
"0.6016656",
"0.58577174",
"0.57509834",
"0.56115276",
"0.55442506",
"0.5538549",
"0.5479685",
"0.5426244",
"0.54222065",
"0.53931034",
"0.53810304",
"0.52857715",
"0.5285419",
"0.528525",
"0.5266104",
"0.5263046",
"0.524547... | 0.7681746 | 0 |
PATCH/PUT /weekday_constraints/1 PATCH/PUT /weekday_constraints/1.json | def update
respond_to do |format|
if @weekday_constraint.update(weekday_constraint_params)
format.html { redirect_to @weekday_constraint, notice: 'Weekday constraint was successfully updated.' }
format.json { render :show, status: :ok, location: @weekday_constraint }
else
format.html { render :edit }
format.json { render json: @weekday_constraint.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weekday_constraint\n @weekday_constraint = WeekdayConstraint.find(params[:id])\n end",
"def weekday_constraint_params\n params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)\n end",
"def create\n @weekday_constraint = WeekdayConstraint.new(weekday_... | [
"0.7113796",
"0.69656956",
"0.67099786",
"0.63941854",
"0.6228021",
"0.5994955",
"0.59733343",
"0.5957577",
"0.58312106",
"0.5657831",
"0.5631886",
"0.56004864",
"0.55685604",
"0.5542169",
"0.5531347",
"0.5514782",
"0.54798675",
"0.5470324",
"0.5469003",
"0.5448787",
"0.54389... | 0.79578316 | 0 |
DELETE /weekday_constraints/1 DELETE /weekday_constraints/1.json | def destroy
@weekday_constraint.destroy
respond_to do |format|
format.html { redirect_to weekday_constraints_url, notice: 'Weekday constraint was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @weekday = Weekday.find(params[:id])\n @weekday.destroy\n\n respond_to do |format|\n format.html { redirect_to weekdays_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @interval_constraint.destroy\n respond_to do |format|\n format.html { redirect_to i... | [
"0.6597039",
"0.6257258",
"0.6135948",
"0.61321276",
"0.61158335",
"0.6110114",
"0.6005453",
"0.6001682",
"0.59832644",
"0.5951277",
"0.5932545",
"0.588972",
"0.588095",
"0.5867513",
"0.5865036",
"0.58613086",
"0.5860889",
"0.5858118",
"0.5854139",
"0.5840277",
"0.5836694",
... | 0.78664935 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_weekday_constraint
@weekday_constraint = WeekdayConstraint.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 weekday_constraint_params
params.require(:weekday_constraint).permit(:day, :name, :constraint_id, :constraint_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Ref: // original code I simply added the acceptance of user input vs having the "HELP ME OUT OF THIS WELL" string hardcoded into the prgoram. I also added the ability to include numbers 0..9 in the script as well. 1337 banner | def banner()
print """
=================================================================
=================================================================
==========International Morse Code translator v 0.0.1 =========
==========Transates user supplied Morse Code to text ============
=================================================================
==========Coded by Rick Flores | nanotechz9l ====================
==========E-mail 0xnanoquetz9l<<\|/>>gmail.com ===================
=================================================================
=================================================================
""".foreground(:blue).bright
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def help; summarize(\"#{banner}\".sub(/\\n?\\z/, \"\\n\")) end",
"def explain_game\n\t\tputs \"In the Secret Number Game, you guess a number between 1 and 10 and, if you pick the right number, you win!\"\n\t\tputs \"Good luck #{@player}!\"\n\tend",
"def more_info\n \tputs \"Which podcast would you like to kno... | [
"0.63906",
"0.6352123",
"0.63123804",
"0.6236599",
"0.62223774",
"0.61803234",
"0.61717564",
"0.61169785",
"0.6095051",
"0.6094317",
"0.6083893",
"0.6067006",
"0.60103965",
"0.6009977",
"0.60073614",
"0.5999005",
"0.5976693",
"0.5962276",
"0.59530103",
"0.59485453",
"0.593377... | 0.63559103 | 1 |
Returns provider based on configured domain name matches, or nil if unmatched For best results, consider the Exchanger.provider result as well. | def provider
EmailAddress::Config.providers.each do |name, defn|
return name if EmailAddress::DomainMatcher.matches?(@host_name, defn[:domains])
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider\n return @provider if defined? @provider\n Config.providers.each do |provider, config|\n if config[:exchanger_match] && matches?(config[:exchanger_match])\n return @provider = provider\n end\n end\n @provider = :default\n end",
"def find_provider(provide... | [
"0.80977505",
"0.70549464",
"0.68169653",
"0.6465162",
"0.6387879",
"0.63629025",
"0.62816674",
"0.6197763",
"0.6148884",
"0.6140221",
"0.6119688",
"0.61143565",
"0.60501146",
"0.6030279",
"0.59808064",
"0.59736705",
"0.5932827",
"0.58955437",
"0.58717304",
"0.5863909",
"0.58... | 0.7716999 | 1 |
def check_for_cancel session[:return_to] ||= company_user_path(session[:company_id] ,session[:user_id]) if params[:button] == "Cancel" redirect_to session.delete(:return_to) end end | def resolve_layout
case action_name
when "edit"
"editlayout"
when "show_image"
"application_png"
else
"application"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_and_redirect\r\n redirect_back\r\n end",
"def check_cancel_submit\n redirect_to matters_path if params[:cancel]\n end",
"def check_for_cancel\n if params[:commit] == \"Cancel\"\n redirect_to forms_path\n end\n end",
"def cancel\n flash[:notice] = \"Canceling accounts is not ... | [
"0.77676696",
"0.759709",
"0.7367247",
"0.7194713",
"0.71496356",
"0.71346927",
"0.7096799",
"0.70705694",
"0.7067757",
"0.70460594",
"0.70327145",
"0.69563353",
"0.6878139",
"0.67065275",
"0.66916233",
"0.66822875",
"0.66822875",
"0.66309255",
"0.66146874",
"0.6612586",
"0.6... | 0.0 | -1 |
use quizzes method to sort out the data | def quizzes
if @quiz_divs
@quiz_divs.map do |quiz_div|
arr = quiz_div.children.inner_text.split("\n").delete_if(&:blank?)
{
title: arr[1],
options: arr[2..-3],
explanation: arr[-2]
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def myquizze_results\n @current_user = get_logged_user\n if @quizze_instance = @current_user.get_latest_quizze_instance\n @quizze = @quizze_instance.get_quizze\n @sorted_affinities = @quizze_instance.sorted_affinities\n @explanations, @hash_dimension2answers, @hash_question_idurl2min_max_weigh... | [
"0.65230846",
"0.63319683",
"0.594961",
"0.58776706",
"0.5803569",
"0.5789615",
"0.5739532",
"0.57153594",
"0.5710512",
"0.5710512",
"0.5678767",
"0.56657684",
"0.5662804",
"0.5623195",
"0.56018525",
"0.5584009",
"0.55725807",
"0.5570002",
"0.55498713",
"0.55464685",
"0.55464... | 0.56399304 | 13 |
metodos Me retorna sueldo | def calculo_de_sueldo(attr={})
retencion = @salario * 0.1
salud = @salario * 0.07
pension = @salario * 0.12
sueldo = @salario - retencion - salud - pension
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suivre; end",
"def mi_carrera\n\n\tend",
"def zuruecksetzen()\n end",
"def private; end",
"def schubert; end",
"def verdi; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def sigla; @nome; end",
"def retornoBusqueda()\nreturn @busqueda\nend",
"def for... | [
"0.7543577",
"0.70416635",
"0.68899274",
"0.65834004",
"0.6473345",
"0.64088166",
"0.6395721",
"0.6395721",
"0.6395721",
"0.6395721",
"0.6283242",
"0.62435704",
"0.61812484",
"0.61591816",
"0.6108985",
"0.61085206",
"0.6073562",
"0.6024866",
"0.60212564",
"0.601153",
"0.59327... | 0.0 | -1 |
CLI will parse all command line options | def initialize(args)
@args = args
@options = OpenStruct.new
parse
validate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_command_line()\n opts = GetoptLong.new(\n [ \"--input-file\" , \"-i\", GetoptLong::REQUIRED_ARGUMENT ],\n [ \"--verbose\" , \"-v\", GetoptLong::NO_ARGUMENT ]\n )\n #----------------------------- defaults\n\n op... | [
"0.803635",
"0.7861017",
"0.7848191",
"0.78104764",
"0.77321523",
"0.7721252",
"0.7697515",
"0.76875573",
"0.7664166",
"0.7626608",
"0.75806016",
"0.75737077",
"0.75731456",
"0.7523304",
"0.75094056",
"0.7481376",
"0.7470525",
"0.74416137",
"0.7418397",
"0.74163747",
"0.73759... | 0.0 | -1 |
Perform actions based on command & options | def execute
Tools.public_send(command, options.configuration_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_action(cmd, options = {})\n # XXX Finish this\n end",
"def run\n \n if parsed_options?\n \n process_command\n end\n \n end",
"def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output... | [
"0.7960666",
"0.72554153",
"0.7117998",
"0.7017757",
"0.700435",
"0.6980806",
"0.6951909",
"0.69421744",
"0.6844444",
"0.68172485",
"0.6792789",
"0.67878175",
"0.6754534",
"0.6754272",
"0.6739037",
"0.67239606",
"0.6698615",
"0.668392",
"0.6578189",
"0.65590954",
"0.6550011",... | 0.0 | -1 |
Extract command + arguments from ARGV | def parse
# Parse all arguments first
option_parser.parse!(arguments)
# Get the first argument, this is our command
cmd = arguments.pop
raise OptionParser::MissingArgument, 'command' unless cmd
# Set the command if it's present
options.command = cmd.to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_arguments!\n return ARGV[0], nil, nil if ARGV.length == 1\n\n raise(ArgumentError, \"Usage: mixtape-bu SOURCE [CHANGES] [DEST]\") unless ARGV.length == 3\n\n ARGV.take(3)\nend",
"def extract_args(*args)\n options = args.extract_options!\n if options.length.positive?\n [args.... | [
"0.71073043",
"0.70720774",
"0.7029388",
"0.6966272",
"0.68718165",
"0.68326324",
"0.6767837",
"0.6765271",
"0.6722819",
"0.66720086",
"0.6652091",
"0.6647991",
"0.66367525",
"0.65813124",
"0.6524584",
"0.6506438",
"0.6464903",
"0.6418978",
"0.6318712",
"0.63096637",
"0.62469... | 0.0 | -1 |
Ensure we have valid data | def validate
raise Tools::InvalidCommandException.new(command, AVAILABLE_COMMANDS) unless valid_command?
raise Tools::MissingConfigurationException.new('You must specify a valid configuration file.') unless options.configuration_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?\n data\n end",
"def valid?\n data\n end",
"def validate_data_format\n unless data.is_a?(Array)\n raise DataFormatError, \"Data set(s) should be given as an array\"\n end\n end",
"def valid?\n @data && @errors.empty?\n end",
"def validated_data\n @schema.v... | [
"0.71942085",
"0.71942085",
"0.69496465",
"0.6933194",
"0.68795663",
"0.68310964",
"0.671113",
"0.65972954",
"0.65937245",
"0.65737116",
"0.65345323",
"0.65303195",
"0.64967173",
"0.64828193",
"0.64828193",
"0.64828193",
"0.64828193",
"0.64828193",
"0.6425028",
"0.64241445",
... | 0.0 | -1 |
CLI option parsing singleton | def option_parser
@parser ||= OptionParser.new do |opts|
opts.banner = "Usage: ./tools [#{AVAILABLE_COMMANDS.join('|')}] <options>"
# Allow user to choose a different configuration file
opts.on('-c', '--config [path]', 'Change configuration file from default.') do |path|
options.configuration_path = path
end
# View program help
opts.on_tail('-h', '--help', 'See program help.') do
puts opts
exit
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_opts\n option_parser.parse(@argv)\n end",
"def parse_options(opts, args); end",
"def parse_cli\n require 'getoptlong'\n require 'rdoc/usage'\n \n opts = GetoptLong.new(\n [ '--help', '-h', GetoptLong::NO_ARGUMENT ],\n [ \"--quote-terms\", '-q', GetoptLong::N... | [
"0.77286905",
"0.75422674",
"0.7542076",
"0.7409308",
"0.7409308",
"0.73883796",
"0.73883796",
"0.7362992",
"0.7329745",
"0.7287945",
"0.7228465",
"0.71843016",
"0.7176019",
"0.716947",
"0.71688426",
"0.7162563",
"0.7141025",
"0.71287274",
"0.71180296",
"0.71133226",
"0.71121... | 0.70824856 | 24 |
=begin rdoc Predicate ends in a quotation mark, returns Boolean =end | def empty?()
@bottles.zero?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Predicate(path, parsed); end",
"def implicit_docstring?\n YARD.implicit_docstring?(docstring, method)\n end",
"def predicate_string_term predicate\n if predicate[0] == '^'\n \"^<#{predicate[1..predicate.length-1]}>\"\n else\n \"<#{predicate}>\"\n end\nend",
"def begin... | [
"0.5924306",
"0.57749313",
"0.5740364",
"0.5618657",
"0.56178963",
"0.5608032",
"0.5575808",
"0.5575404",
"0.5563643",
"0.5563643",
"0.55439526",
"0.55439526",
"0.5542096",
"0.5522708",
"0.5521976",
"0.5494024",
"0.5485341",
"0.5472267",
"0.54436064",
"0.5433529",
"0.5424686"... | 0.0 | -1 |
=begin rdoc Destructive method, ends in a exclamation mark =end | def singOneVerse!()
puts sing("On the wall, ") + sing("\n") + takeOneDown! + sing(" on the wall \n\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def -@; end",
"def private; end",
"def delelte\n\n end",
"def specialty; end",
"def silly_adjective; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def deter\n \n end",
"def probers; end",
"def -@()\n #This is a stub, used for indexing\n end",
"def... | [
"0.7089336",
"0.70665765",
"0.68817496",
"0.68809897",
"0.6845547",
"0.6791525",
"0.6791525",
"0.6791525",
"0.6791525",
"0.67759305",
"0.66990954",
"0.66709274",
"0.6666021",
"0.6666021",
"0.6666021",
"0.6666021",
"0.66405976",
"0.6627282",
"0.6599342",
"0.6599342",
"0.659142... | 0.0 | -1 |
GET /next_actions/1 GET /next_actions/1.json | def show
@next_action = NextAction.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @next_action }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @next_action = current_user.next_actions.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_action }\n end\n end",
"def next_actions!\n actions = migrate_actions :mapper\n actions += migrate_actions :reducer\n actions += reduce_... | [
"0.7097086",
"0.66801596",
"0.6520351",
"0.6407268",
"0.63679063",
"0.6316108",
"0.62870437",
"0.6021235",
"0.60075116",
"0.6000905",
"0.59971225",
"0.59967303",
"0.59967303",
"0.5986891",
"0.5962236",
"0.5947535",
"0.59370565",
"0.59219944",
"0.5864031",
"0.5854869",
"0.5828... | 0.7480718 | 0 |
GET /next_actions/new GET /next_actions/new.json | def new
@next_action = current_user.next_actions.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @next_action }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n if params[:project_id]\n project = Project.find(params[:project_id])\n @next_action = current_user.next_actions.build(params[:act])\n @next_action.project_id = project.id\n \n respond_to do |format|\n if @next_action.save\n format.html { redirect_to pr... | [
"0.68126523",
"0.67858696",
"0.6607946",
"0.6579629",
"0.6529727",
"0.6383268",
"0.63546675",
"0.63040096",
"0.6294551",
"0.62184983",
"0.6213927",
"0.6203718",
"0.6202217",
"0.6145577",
"0.6137222",
"0.6129728",
"0.60786766",
"0.6019078",
"0.601624",
"0.6010233",
"0.60071415... | 0.80571014 | 0 |
POST /next_actions POST /next_actions.json | def create
if params[:project_id]
project = Project.find(params[:project_id])
@next_action = current_user.next_actions.build(params[:act])
@next_action.project_id = project.id
respond_to do |format|
if @next_action.save
format.html { redirect_to project, notice: 'Next Action was successfully created.' }
format.json { render json: @next_action, status: :created, location: @next_action }
else
format.html { render action: "new" }
format.json { render json: @next_action.errors, status: :unprocessable_entity }
end
end
else
@next_action = current_user.next_actions.build(params[:act])
respond_to do |format|
if @next_action.save
format.html { redirect_to @next_action, notice: 'Next Action was successfully created.' }
format.json { render json: @next_action, status: :created, location: @next_action }
else
format.html { render action: "new" }
format.json { render json: @next_action.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @next_action = current_user.next_actions.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @next_action }\n end\n end",
"def next_actions!\n actions = migrate_actions :mapper\n actions += migrate_actions :reducer\n actions += reduce_... | [
"0.715589",
"0.6899558",
"0.6774813",
"0.638255",
"0.6101294",
"0.5970754",
"0.5946884",
"0.5929872",
"0.5887739",
"0.57836694",
"0.57672626",
"0.573619",
"0.5710224",
"0.5674904",
"0.56644535",
"0.5661915",
"0.5619158",
"0.55812746",
"0.5543693",
"0.55302465",
"0.5511056",
... | 0.64456546 | 3 |
PUT /next_actions/1 PUT /next_actions/1.json | def update
@next_action = NextAction.find(params[:id])
respond_to do |format|
if @next_action.update_attributes(params[:act])
format.html { redirect_to @next_action, notice: 'Next Action was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @next_action.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @actions = args[:actions] if args.key?(:actions)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end",
"def new\n @next_action = current_user.next_actions.build\n\n respond_to do |format|\n format.html # new.html.erb\n fo... | [
"0.6955463",
"0.63703656",
"0.62510127",
"0.62441003",
"0.61174613",
"0.60265386",
"0.6008339",
"0.5962743",
"0.59089756",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
"0.59064907",
... | 0.72105753 | 0 |
DELETE /next_actions/1 DELETE /next_actions/1.json | def destroy
@next_action = NextAction.find(params[:id])
@next_action.destroy
respond_to do |format|
format.html { redirect_to actions_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n ruta = \"/actions/#{action_id}\"\n client.delete(ruta)\n end",
"def delete(action, **args); end",
"def destroy\n @next_step = NextStep.find(params[:id])\n @next_step.destroy\n\n respond_to do |format|\n format.html { redirect_to next_steps_url }\n format.json { head... | [
"0.7581382",
"0.69087195",
"0.6464412",
"0.645249",
"0.6404421",
"0.6404421",
"0.6402229",
"0.6400883",
"0.6377735",
"0.6377574",
"0.63199025",
"0.63145983",
"0.62911147",
"0.6275194",
"0.6254454",
"0.62527305",
"0.62346315",
"0.61927235",
"0.6176248",
"0.6176248",
"0.6176248... | 0.7749014 | 0 |
MM2: Overwrite the default cubeless engine marketing_image_tag method to change the width and height | def marketing_image_tag(message)
link_to_if(message.link_to_url, image_tag( marketing_image_path(message), :alt => '', :width => "394", :height => "150"),message.link_to_url) if message
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end",
"def course_image_preview(entity)\n return '' if entity.image.blank?\n\n versions = \"#{entity.image.preview_2x.url} 2x\"\n image_tag(entity.image.preview.url, alt: entity.title, srcset: versions)\n end",
"def xf_... | [
"0.62898046",
"0.61662716",
"0.61253864",
"0.6064011",
"0.60363024",
"0.60363024",
"0.60363024",
"0.60363024",
"0.60363024",
"0.60363024",
"0.60155135",
"0.60076654",
"0.5922267",
"0.5909879",
"0.5856931",
"0.5826851",
"0.5822646",
"0.58180934",
"0.5813877",
"0.58072454",
"0.... | 0.5354255 | 91 |
pulls data from Sunlight foundation congress API, using 'congress' Ruby Gem | def index
Congress.key = '0ef8e130fe124b69a2388d253fd05e63'
#locating the congressmen by the logged on users zip code
legislators = Congress.legislators_locate(current_user.zip)["results"]
#isolating HOUSE (as opposed to House + Senate). Returning house member listed
#in the event more than one appear
@representative = legislators.select { |leg| leg.chamber == "house" }[0]
#commented out aborted grading system
#@grade = Grade.find_by_user_id_and_bioguide_id(current_user.id, @representative.bioguide_id)
#sets up comments system
@repcomments = Repcomment.find_all_by_bioguide_id(@representative.bioguide_id)
#pulls recent votes from Sunlight API
@votes = Congress.votes["results"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_api\n\t\tputs \"Getting info on elected officials for zipcode: #{zip_code}\"\n\t\t@api_data_on_electeds = JSON.load RestClient.get \"https://congress.api.sunlightfoundation.com/legislators/locate?zip=#{zip_code}&apikey=952d630dfb75498ab63de7a362a85335\"\n\tend",
"def fetch(options = {})\n url = b... | [
"0.63390404",
"0.63387054",
"0.60434455",
"0.60184056",
"0.577277",
"0.5771873",
"0.570652",
"0.563756",
"0.559842",
"0.55941164",
"0.5553796",
"0.55086",
"0.5446049",
"0.5427039",
"0.54269004",
"0.5415405",
"0.5399211",
"0.53982365",
"0.5388741",
"0.53882474",
"0.5386853",
... | 0.55998975 | 8 |
Manage for any color list | def act_anylist(colorlist, options, server_id)
raise MessagingException, t.blacklist.not.loaded unless master.modules.key?(options.who)
mod = mod(options.who)
toAdd = [options.chan]
toAdd = mod("admin").chans if options.all?
if options.type == "add"
modify_status colorlist, t.blacklist.act.added, toAdd, options, mod, true, server_id
end
if options.type == "del"
modify_status colorlist, t.blacklist.act.deleted, toAdd, options, mod, false, server_id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_for_colors; end",
"def colors; end",
"def color(*values); end",
"def color(*values); end",
"def add_color\n if !color\n self.color = %w(\n #000000 #0000FF #00FF00 #FF0000 #FFFF00 #9900CC\n #CC0066 #00FFFF #FF00FF #C0C0C0 #00008B #FFD700\n #FFA500 #FF1493 #FF00FF #F0FFF... | [
"0.71836215",
"0.70422316",
"0.68634444",
"0.68634444",
"0.683087",
"0.6757881",
"0.6598978",
"0.6593697",
"0.6520501",
"0.6503952",
"0.64989513",
"0.6434429",
"0.6403567",
"0.6398101",
"0.6371392",
"0.6329364",
"0.63287085",
"0.6327377",
"0.6327377",
"0.6327377",
"0.62750006... | 0.0 | -1 |
Do the job of adding/deleting | def modify_status(method, action_string, toAdd, options, mod, do_add, server_id)
toAdd.each do |chan|
talk(options.from_who, t.blacklist.act.global(chan, action_string, method, options.who), server_id)
mod.send(("un_" + method), chan) unless do_add
mod.send(method, chan) if do_add
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n \n end",
"def delete_operations; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def done_adding(*) end",
"def delete\n \n end",
"def add \n end",
"def delete\n end",
"def delete\n\n\tend",
"def delete\n end",
"def delete... | [
"0.67627645",
"0.67581487",
"0.6479457",
"0.6479457",
"0.6479457",
"0.6479457",
"0.63846755",
"0.6349676",
"0.6280146",
"0.6209642",
"0.6164026",
"0.61527604",
"0.61527604",
"0.61527604",
"0.61527604",
"0.61527604",
"0.61527604",
"0.61527604",
"0.6148207",
"0.61346155",
"0.60... | 0.0 | -1 |
Is the chan blacklisted? | def in_blacklist?(chan)
@blackList.include?(chan.downcase) if blacklist?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blacklisted?(channel, nick)\n return false if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].include?(nick)\n end",
"def is_channel_blacklisted?(channel_name)\n !ENV[\"CHANNEL_BLACKLIST\"].nil? && ENV[\"CHANNEL_BLACKLIST\"].split(\",\").find{ |a| a.gsub(\"#\", \"\").strip == channel_name ... | [
"0.7920067",
"0.7615517",
"0.74722815",
"0.7438271",
"0.7380521",
"0.7113132",
"0.6795921",
"0.6733704",
"0.67138255",
"0.67058975",
"0.6685923",
"0.66241616",
"0.65777254",
"0.65385354",
"0.65377647",
"0.6491646",
"0.6477628",
"0.6407497",
"0.6382794",
"0.6341555",
"0.633685... | 0.81905717 | 0 |
Is the chan whitelisted? | def in_whitelist?(chan)
return @whiteList.include?(chan.downcase) if whitelist?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_blacklist?(chan)\n @blackList.include?(chan.downcase) if blacklist?\n end",
"def blacklisted?(channel, nick)\n return false if not @blacklist[channel].is_a?(Array)\n @blacklist[channel].include?(nick)\n end",
"def is_channel_blacklisted?(channel_name)\n !ENV[\"CHANNEL_BLACKLIST\"].nil? &... | [
"0.7679673",
"0.7371595",
"0.72186685",
"0.6963999",
"0.6860579",
"0.6854552",
"0.67722136",
"0.6719608",
"0.66713506",
"0.66545594",
"0.64600116",
"0.6453088",
"0.64510363",
"0.6435301",
"0.63914555",
"0.63364893",
"0.6327389",
"0.6315006",
"0.62931705",
"0.6271434",
"0.6268... | 0.8291955 | 0 |
Check if an instance is authorized in a chan | def act_authorized_with_blacklist?(instance, msg)
result = act_authorized_without_blacklist?(instance, msg)
return result unless msg.element.is_a? Linael::Irc::Privmsg
mod = mod(instance.class::Name)
result &= !mod.in_blacklist?(msg.place)
result &= mod.in_whitelist?(msg.place)
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_instance_permissions\n unless @bot_instance.user == current_user || current_user.is_owner?(@bot_instance.bot) || current_user.is_admin?\n render status: :forbidden, plain: \"You're not allowed to modify this instance\" and return\n end\n\n render status: :forbidden, plain: 'This instance do... | [
"0.64766246",
"0.64395356",
"0.6387061",
"0.6380646",
"0.6342629",
"0.6302006",
"0.630177",
"0.62956965",
"0.629123",
"0.6276678",
"0.62524635",
"0.6237068",
"0.6220886",
"0.61942416",
"0.61873585",
"0.6184865",
"0.6172925",
"0.6160967",
"0.6139461",
"0.6126299",
"0.61115265"... | 0.6698016 | 0 |
=> Make sure you change this to the name of your code file! Save that file into this repo. | def separate_comma(number)
case number.to_s.length
when 0..3
puts number.to_s
when 4..6
puts number.to_s.insert(-4,",")
when 7..9
puts number.to_s.insert(-4,",").insert(-8,",")
when 10..12
puts number.to_s.insert(-4,",").insert(-8,",").insert(-12,",")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_source_file; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def updated_source_file?; end",
"def src; end",
"def src; end",
"def src; end",
"def project_filename; end",
"def source_location; end",
... | [
"0.6821458",
"0.6594034",
"0.6594034",
"0.6594034",
"0.6594034",
"0.6594034",
"0.6594034",
"0.6594034",
"0.64349914",
"0.63656425",
"0.63656425",
"0.63656425",
"0.6337679",
"0.62216777",
"0.621762",
"0.6203383",
"0.6203383",
"0.6203383",
"0.6203383",
"0.61745214",
"0.61638343... | 0.0 | -1 |
def current_player(board) if turn_count(board) % 2 end | def current_player(board)
turn_count(board) % 2 == 0 ? "X" : "O"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_player\n if board.turn_count.odd?\n player_2\n elsif board.turn_count.even?\n player_1\n end\n end",
"def current_player\n board.turn_count.even? ? @player_1 : @player_2\n end",
"def current_player\n board.turn_count % 2 == 0 ? player_1 : player_2\n end",
"def ... | [
"0.8850004",
"0.87865525",
"0.8780555",
"0.8768195",
"0.8764739",
"0.87511826",
"0.8750581",
"0.8744386",
"0.8738484",
"0.87289035",
"0.8698882",
"0.8698318",
"0.8683913",
"0.86829966",
"0.8677784",
"0.8677784",
"0.8677784",
"0.8677784",
"0.86686176",
"0.8663312",
"0.86618817... | 0.847955 | 74 |
Never trust parameters from the scary internet, only allow the white list through. | def enrollment_params
params.require(:enrollment).permit(:section_id, :student_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.