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 |
|---|---|---|---|---|---|---|
Appends existing TIFF image to another existing TIFF image (i.e. merges TIFF images) | def append_tiff_from_storage
puts('Appends existing TIFF image to another existing TIFF image')
append_file_name = 'Append.tiff' # Image file name to be appended to original one
upload_sample_image_to_cloud
upload_image_to_cloud(append_file_name, File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, append_file_name))
# Update TIFF Image parameters according to fax parameters
folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage
storage = nil # We are using default Cloud Storage
update_request = AsposeImagingCloud::AppendTiffRequest.new(
get_sample_image_file_name, append_file_name, storage, folder)
puts('Call AppendTiff')
imaging_api.append_tiff(update_request)
# Download updated file to local storage
download_request = AsposeImagingCloud::DownloadFileRequest.new(
File.join(ImagingBase::CLOUD_PATH, get_sample_image_file_name), storage)
updated_image = imaging_api.download_file(download_request)
save_updated_image_to_output('AppendToTiff.tiff', updated_image)
puts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(other_image)\n raise 'an image class must be supplied' unless other_image.is_a? Image\n raise 'cannot merge if the user is different' unless other_image.user == user\n raise 'cannot merge if the account_id is different' unless other_image.account_id == account_id\n ... | [
"0.61741656",
"0.6001265",
"0.5858601",
"0.577929",
"0.55328095",
"0.55000424",
"0.5443584",
"0.54142827",
"0.53489655",
"0.53430873",
"0.5236349",
"0.5224159",
"0.52176",
"0.5184148",
"0.5158657",
"0.5064444",
"0.5064444",
"0.5038985",
"0.50312716",
"0.502292",
"0.5006569",
... | 0.7009079 | 0 |
GET /events GET /events.json | def index
@events = Event.order(sort_column + ' ' + sort_direction)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @events }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}... | [
"0.8337294",
"0.82393",
"0.7943906",
"0.7928331",
"0.77682066",
"0.77408546",
"0.76701826",
"0.7665501",
"0.76581633",
"0.7642472",
"0.76212007",
"0.7615658",
"0.7615658",
"0.7612881",
"0.75687",
"0.7522498",
"0.7488667",
"0.74813455",
"0.74698067",
"0.7441679",
"0.74408287",... | 0.0 | -1 |
GET /events/1 GET /events/1.json | def show
@event = Event.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @event }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @event = Event.find(params[:id])\n render json: @event\n end",
"def get(event_id)\n @client.request \"events/#{event_id}\"\n end",
"def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @use... | [
"0.75022924",
"0.74003553",
"0.7360236",
"0.73483384",
"0.734628",
"0.7336635",
"0.73162717",
"0.7286345",
"0.7280093",
"0.72448486",
"0.722994",
"0.7218412",
"0.7218412",
"0.721763",
"0.721763",
"0.72140783",
"0.7203632",
"0.7198198",
"0.71961105",
"0.7189425",
"0.7189013",
... | 0.7191539 | 43 |
GET /events/new GET /events/new.json | def new
@event = Event.new
3.times { @event.attachments.build }
respond_to do |format|
format.html # new.html.erb
format.json { render json: @event }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @event = Event.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end",
"def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end",
... | [
"0.81609446",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513",
"0.81505513"... | 0.0 | -1 |
POST /events POST /events.json | def create
@event = Event.new(params[:event])
respond_to do |format|
if @event.save
format.html { redirect_to @event, notice: 'Event was successfully created.' }
format.json { render json: @event, status: :created, location: @event }
else
format.html { render action: "new" }
format.json { render json: @event.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_event event, data={}\n data[:event] = event\n post '/event', data\n end",
"def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end",
"def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end",
"def crea... | [
"0.7714071",
"0.7611226",
"0.76028967",
"0.7541319",
"0.7444731",
"0.73206913",
"0.73138195",
"0.728203",
"0.7251226",
"0.7235907",
"0.7235907",
"0.7215051",
"0.71682763",
"0.7150409",
"0.7126664",
"0.7118896",
"0.7117831",
"0.71162695",
"0.70964044",
"0.70907074",
"0.7083036... | 0.7018503 | 37 |
PUT /events/1 PUT /events/1.json | def update
@event = Event.find(params[:id])
if @event.update_attributes(params[:event])
redirect_to @event, :notice => "Termin erfolgreich gespeichert."
else
render :action => 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @event.update(event_params)\n render json: @event, status: 201\n else\n render json: { message: \"Error. Error. Please try again.\"}, status: 400\n end\n end",
"def put_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\... | [
"0.75664943",
"0.74722904",
"0.7472032",
"0.7430477",
"0.7370732",
"0.7366599",
"0.7356629",
"0.73164594",
"0.73164594",
"0.73085743",
"0.72540325",
"0.72540325",
"0.72351176",
"0.7175737",
"0.71719027",
"0.7161037",
"0.7161037",
"0.7160709",
"0.71240234",
"0.71132576",
"0.70... | 0.0 | -1 |
DELETE /events/1 DELETE /events/1.json | def destroy
@event = Event.find(params[:id])
@event.destroy
respond_to do |format|
format.html { redirect_to events_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_... | [
"0.769268",
"0.76872975",
"0.76872975",
"0.76872975",
"0.7680665",
"0.7585337",
"0.75682765",
"0.7560537",
"0.75407815",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7540473",
"0.7539941",... | 0.75145763 | 67 |
Produce una matrice di rotazione premoltiplicativa attorno all'asse x | def get_x_rotation_matrix(alpha)
Matrix[
[1.0, 0.0, 0.0, 0.0],
[0.0, Math.cos(alpha), -Math.sin(alpha), 0.0],
[0.0, Math.sin(alpha), Math.cos(alpha), 0.0],
[0.0, 0.0, 0.0, 1.0]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_row\n return [ self.run, self.rise * -1, (p1.y * self.run - self.rise*p1.x)]\n end",
"def matricula\n end",
"def matrix\n end",
"def x(escalar)\n maux=Array.new(@nFil) { Array.new(@mCol) }\n \n (@nFil).times do |i|\n (@mCol).times do |j|\n maux[i][j] = @matri... | [
"0.5693579",
"0.5467707",
"0.54469603",
"0.5420482",
"0.53573006",
"0.53573006",
"0.529591",
"0.52841896",
"0.52515054",
"0.52499425",
"0.52153283",
"0.51736885",
"0.51408595",
"0.50721747",
"0.5055609",
"0.5043943",
"0.5019113",
"0.4993827",
"0.4993557",
"0.49852735",
"0.498... | 0.48998326 | 25 |
Runs the test case. | def test_importNode07
doc = nil
aNewDoc = nil
element = nil
aNode = nil
attributes = nil
name = nil
attr = nil
lname = nil
namespaceURI = "http://www.nist.gov";
qualifiedName = "emp:employee";
doc = load_document("staffNS", true)
aNewDoc = load_document("staff", true)
element = aNewDoc.createElementNS(namespaceURI, qualifiedName)
aNode = doc.importNode(element, false)
attributes = aNode.attributes()
assertSize("throw_Size", 1, attributes)
name = aNode.nodeName()
assert_equal("emp:employee", name, "nodeName")
attr = attributes.item(0)
lname = attr.localName()
assert_equal("defaultAttr", lname, "lname")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n print_banner\n @test_plan.each do |plan|\n found_nodes = nodes(plan)\n if found_nodes\n found_nodes.each { |node| execute_plan_tests(node, plan) }\n end\n end\n exit @ret_code\n end",
"def run\n\n @startDate = Time.now.to_i * 1000\n @status... | [
"0.7799092",
"0.7670545",
"0.75712216",
"0.75627315",
"0.75226235",
"0.75201446",
"0.74722594",
"0.7330742",
"0.7330742",
"0.72492516",
"0.72388816",
"0.72313887",
"0.72023034",
"0.7136023",
"0.70817155",
"0.7047509",
"0.7020568",
"0.6938718",
"0.6918842",
"0.6867642",
"0.685... | 0.0 | -1 |
Gets URI that identifies the test. | def targetURI
"http://www.w3.org/2001/DOM-Test-Suite/tests/Level-1/importNode07"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getURI()\n return @uri.to_s\n end",
"def uri\n @uri.to_s\n end",
"def uri\n uri_for({}, nil)\n end",
"def uri\n return @uri\n end",
"def uri\n return @uri\n end",
"def uri\n @uri\n end",
"def uri\n @uri\n end"... | [
"0.7387945",
"0.7351851",
"0.71513367",
"0.7137951",
"0.7137951",
"0.7114108",
"0.7114108",
"0.7086164",
"0.70651335",
"0.6988005",
"0.6925742",
"0.6925742",
"0.69119173",
"0.69119173",
"0.6861145",
"0.68302125",
"0.68073744",
"0.67857945",
"0.6764499",
"0.6764499",
"0.675217... | 0.0 | -1 |
Image manipulate Resizing can be wrong when .EXT of file is wrong | def strict_resize image, w, h
image.resize "#{ w }x#{ h }!"
image
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize_picture picture_owner, path, filename_extension\n\n # if filename_extension == 'jpg'\n resize_factor = \"PICTURE_#{picture_owner.upcase}_PREVIEW_SIZE\".constantize.first # e.g. *PICTURE_COACH_PREVIEW_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_f... | [
"0.72622323",
"0.70233345",
"0.68927896",
"0.6849576",
"0.6684884",
"0.64868003",
"0.6485243",
"0.6483435",
"0.6455015",
"0.6436636",
"0.6432602",
"0.6417946",
"0.6406757",
"0.6397087",
"0.63838613",
"0.63602746",
"0.6323126",
"0.63132304",
"0.63073623",
"0.62921274",
"0.6248... | 0.6043332 | 34 |
scale = original_iamge[:width].to_f / image_on_screen[:width].to_f usually scale should be 1 | def crop image, x0 = 0, y0 = 0, w = 100, h = 100, scale = 1
x0 = (x0.to_f * scale).to_i
y0 = (y0.to_f * scale).to_i
w = (w.to_f * scale).to_i
h = (h.to_f * scale).to_i
image.crop "#{ w }x#{ h }+#{ x0 }+#{ y0 }"
image
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_by_pixels(dimensions)\n out_pixels = sqrt(options[:width] * options[:height]).truncate\n src_pixels = sqrt(dimensions[0] * dimensions[1]).truncate\n out_pixels / src_pixels.to_f\n end",
"def GetImageScale()\n\t\treturn @img_scale;\n\tend",
"def fullwidth\n return self.bit... | [
"0.71910375",
"0.7097154",
"0.7045114",
"0.6847256",
"0.6820939",
"0.68075377",
"0.66945076",
"0.6647444",
"0.6521559",
"0.65080374",
"0.64740944",
"0.64687574",
"0.6427284",
"0.6403538",
"0.6379229",
"0.6340301",
"0.6327297",
"0.63096726",
"0.6307333",
"0.6285941",
"0.628581... | 0.0 | -1 |
, :message instance methods | def deliver!
self.do_deliver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message(message) end",
"def message( message )\n\tend",
"def message; end",
"def message; end",
"def message; end",
"def message; end",
"def message; end",
"def message; end",
"def message() end",
"def msg(message)\n end",
"def message\n end",
"def message; Message.new; end",
"def... | [
"0.85979795",
"0.8378066",
"0.8154617",
"0.8154617",
"0.8154617",
"0.8154617",
"0.8154617",
"0.8154617",
"0.8128793",
"0.8017373",
"0.7996192",
"0.79782015",
"0.7779669",
"0.7779669",
"0.77296764",
"0.77103895",
"0.7691525",
"0.7688421",
"0.7561985",
"0.75408506",
"0.7525254"... | 0.0 | -1 |
make sure we have the message without default field | def message_text
clear_default_fields
result = self.message
reset_default_fields
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_valid_message; nil; end",
"def not_valid_message; nil; end",
"def default_messages=(_arg0); end",
"def test_generate_message_blank_with_default_message\n assert_equal \"can’t be blank\", @person.errors.generate_message(:title, :blank)\n end",
"def test_generate_message_empty_with_default_messag... | [
"0.7641877",
"0.7641877",
"0.68796325",
"0.67119354",
"0.6693178",
"0.6635683",
"0.6629244",
"0.6625963",
"0.66057205",
"0.66011995",
"0.6588887",
"0.65215915",
"0.64992106",
"0.6418044",
"0.6415026",
"0.64002913",
"0.63732433",
"0.63675946",
"0.63432",
"0.63432",
"0.63432",
... | 0.68834156 | 2 |
Route methods Main page | def root
render :json => JSONResponse.json(0, "Welcome!")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def route_index; end",
"def route\n #TODO\n end",
"def _routes; end",
"def... | [
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7879078",
"0.7760167",
"0.7628666",
"0.7268596",
"0.7265262",
"0.70528877",
"0.699742",
"0.6870333",
"0.68204576",
"0.6798485",
"0.6798485",
... | 0.0 | -1 |
Exception rescuing method. Integer codes are used for systemwide exception, the alphanumeric codes are for more specific errors. A regular exception | def exception_json(exception,code=500)
render :json => Status::Errors.exception_json(exception, code).to_json, :status => code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raise(exception); end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_from(exception); end",
"def rescue_action(e); raise e; end",
"def exception; end",
"def exception; end",
"def exc... | [
"0.7165418",
"0.7155438",
"0.7155438",
"0.7155438",
"0.7155438",
"0.71400726",
"0.71260273",
"0.68586934",
"0.68586934",
"0.68586934",
"0.68586934",
"0.68586934",
"0.682984",
"0.6779175",
"0.6762418",
"0.6739181",
"0.6687594",
"0.6675988",
"0.6666675",
"0.66664976",
"0.666280... | 0.0 | -1 |
No route was found. | def no_route_exception_json(exception)
code = 404
render :json => Status::Errors.exception_json(exception, code).to_json, :status => code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def undefined_route\n routing_error!\n end",
"def no_route\n self.response[:body] = \"route not found for: '#{self.env['REQUEST_URI']}'\"\n self.response[:status_code] = 404\n end",
"def no_routes\n # no need to do anything here either.\n end",
"def no_routes\n end",
"... | [
"0.8046172",
"0.7991195",
"0.76937324",
"0.76676756",
"0.74779207",
"0.7408969",
"0.73745126",
"0.73096585",
"0.72957605",
"0.726977",
"0.72595406",
"0.7224247",
"0.7224247",
"0.7224247",
"0.7224247",
"0.7224247",
"0.7224247",
"0.72233516",
"0.72087944",
"0.71538496",
"0.7047... | 0.0 | -1 |
The resource was not found or is gone. | def does_not_exist_json(exception=nil)
message = exception.message if !exception.nil?
exception = AppError::UndefinedRouteOrActionError.new
code = exception.code
render :json => Status::Errors.exception_json(exception, code, message).to_json, :status => code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_not_found\n flash.now.alert = \"notifications.document.not_found\"\n @info = { id: params[:id] }\n render \"shared/html/404\" and return\n end",
"def handle_resource_not_found(msg = 'Not found.')\r\n flash.now[:notice] = msg\r\n @web_analytics.page_stack = ['Admin', 'Resource Not Fou... | [
"0.636349",
"0.62843853",
"0.62494034",
"0.6230792",
"0.62205577",
"0.6143138",
"0.61423594",
"0.6133038",
"0.6109996",
"0.6062923",
"0.60106754",
"0.60067475",
"0.598609",
"0.5983417",
"0.59780145",
"0.5967421",
"0.5930613",
"0.58750075",
"0.58740735",
"0.5855029",
"0.585258... | 0.0 | -1 |
Method is not allowed. | def record_not_unique_json(exception)
code = 405
original_message = exception.message
exception = ActiveRecord::RecordNotUnique.new(Status::Errors::ERROR_NON_UNIQUE_DB_ID["message"])
render :json => Status::Errors.exception_json(exception, code, original_message).to_json, :status => code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def `(*args); forbidden(__method__); end",
"def private_metho... | [
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.73048013",
"0.71526605",
"0.7023407",
"0.6977093",
"0.69003445",
"0.6798938",
"0.67812485",
"0.67418903",
"0.67418903",
... | 0.0 | -1 |
Invalid JSON used for our configuration. | def invalid_json_json(exception)
code = 500
render :json => Status::Errors.exception_json("We are currently experiencing issues with our data server, please try again soon.", code).to_json, :status => code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_format\n JSON.parse(content) && nil if content\n rescue JSON::ParserError => err\n err.message\n end",
"def validate_format\n JSON.parse(content) && nil if content\n rescue JSON::ParserError => err\n err.message\n end",
"def fix_malformed_json(malformed_json)\n return malforme... | [
"0.66833407",
"0.66833407",
"0.65797335",
"0.6351251",
"0.6296096",
"0.6244065",
"0.61983657",
"0.6115238",
"0.6089773",
"0.6044581",
"0.6027647",
"0.6011292",
"0.60111916",
"0.59835905",
"0.59801924",
"0.59801924",
"0.59425426",
"0.59346706",
"0.5933757",
"0.5876584",
"0.586... | 0.67612433 | 0 |
All possible pairs of pieces | def pairs
@pieces.combination(2).to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pairs\n seq = to_a\n seq.zip([*seq[1..-1], unit.advance(to)])\n end",
"def all_pairs\n all_pairs = self.pairs + self.reverse_pairs\n all_pairs.uniq!\n end",
"def every_possible_pairing_of_word(arr)\n i1 = arr\n i2 = []\n i1.combination(2).to_a\nend",
"def pairs(ring)\n ring.each_c... | [
"0.65870905",
"0.6571787",
"0.65041363",
"0.64706194",
"0.64641786",
"0.64543986",
"0.64086646",
"0.638834",
"0.6382433",
"0.63481873",
"0.63481873",
"0.6337747",
"0.63077456",
"0.62984926",
"0.6297608",
"0.6271361",
"0.6243481",
"0.6235391",
"0.6190097",
"0.6187677",
"0.6166... | 0.810931 | 1 |
GET /kansei_buhins/1 GET /kansei_buhins/1.json | def show
@kansei_buhin = KanseiBuhin.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @kansei_buhin }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @buchung = Buchung.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @buchung }\n end\n end",
"def show\n @lich_su_binh_bau = LichSuBinhBau.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb... | [
"0.6994087",
"0.67499775",
"0.6714746",
"0.66419196",
"0.6632724",
"0.6623885",
"0.6596611",
"0.6568357",
"0.65605146",
"0.6483976",
"0.6471406",
"0.64261603",
"0.63488626",
"0.6325662",
"0.6310468",
"0.6304809",
"0.6282256",
"0.6273688",
"0.6264302",
"0.62628794",
"0.6230954... | 0.7059854 | 0 |
GET /kansei_buhins/new GET /kansei_buhins/new.json | def new
@kansei_buhin = KanseiBuhin.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @kansei_buhin }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @bokin = Bokin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bokin }\n end\n end",
"def new \n @buchung = Buchung.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @buchung }\n ... | [
"0.761673",
"0.7569702",
"0.75649667",
"0.7459997",
"0.74100906",
"0.74056053",
"0.7312473",
"0.7308684",
"0.72923225",
"0.72871196",
"0.72633046",
"0.72590375",
"0.724607",
"0.7232557",
"0.72045356",
"0.72044945",
"0.7200093",
"0.71833986",
"0.71821725",
"0.71812034",
"0.716... | 0.7692929 | 0 |
POST /kansei_buhins POST /kansei_buhins.json | def create
@kansei_buhin = KanseiBuhin.new(params[:kansei_buhin])
respond_to do |format|
if @kansei_buhin.save
format.html { redirect_to @kansei_buhin, notice: 'Kansei buhin was successfully created.' }
format.json { render json: @kansei_buhin, status: :created, location: @kansei_buhin }
else
format.html { render action: "new" }
format.json { render json: @kansei_buhin.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @bakusokukun = Bakusokukun.new(bakusokukun_params)\n\n respond_to do |format|\n if @bakusokukun.save\n format.html { redirect_to @bakusokukun, notice: 'Bakusokukun was successfully created.' }\n format.json { render :show, status: :created, location: @bakusokukun }\n else... | [
"0.6347688",
"0.633545",
"0.6265529",
"0.6234046",
"0.62215424",
"0.62206763",
"0.6160601",
"0.61543286",
"0.6086408",
"0.60515094",
"0.60469353",
"0.60360444",
"0.598602",
"0.59747726",
"0.5949141",
"0.594166",
"0.5935959",
"0.591948",
"0.5917004",
"0.5917004",
"0.59156334",... | 0.684998 | 0 |
PUT /kansei_buhins/1 PUT /kansei_buhins/1.json | def update
@kansei_buhin = KanseiBuhin.find(params[:id])
respond_to do |format|
if @kansei_buhin.update_attributes(params[:kansei_buhin])
format.html { redirect_to @kansei_buhin, notice: 'Kansei buhin was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @kansei_buhin.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @sinh_vien = SinhVien.find(params[:id])\n\n respond_to do |format|\n if @sinh_vien.update_attributes(params[:sinh_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n ... | [
"0.68814063",
"0.670075",
"0.65591913",
"0.6488539",
"0.6405582",
"0.6348251",
"0.6337876",
"0.63248795",
"0.6289802",
"0.6284423",
"0.6229172",
"0.62042034",
"0.61847705",
"0.6167284",
"0.6149205",
"0.61369705",
"0.61307514",
"0.61276966",
"0.6114106",
"0.61093235",
"0.61004... | 0.685274 | 1 |
DELETE /kansei_buhins/1 DELETE /kansei_buhins/1.json | def destroy
@kansei_buhin = KanseiBuhin.find(params[:id])
@kansei_buhin.destroy
respond_to do |format|
format.html { redirect_to kansei_buhins_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @giang_vien = GiangVien.find(params[:id])\n @giang_vien.des... | [
"0.7151887",
"0.71441704",
"0.6996511",
"0.6974747",
"0.6937264",
"0.68778795",
"0.68375856",
"0.68362015",
"0.68356115",
"0.6816617",
"0.68122745",
"0.6806453",
"0.67842805",
"0.67842805",
"0.67842805",
"0.67842805",
"0.67731696",
"0.6773065",
"0.67719656",
"0.675696",
"0.67... | 0.72041744 | 0 |
Search params : buhinNm katashikiCdFrom katashikiCdTo katashikiNm | def search
# 検索条件設定
conditions = KanseiBuhin.where("1 = ?", 1)
conditions = conditions.where("\"buhinNm\" LIKE ?", params[:buhinNm] + "%") if params[:buhinNm] != ""
conditions = conditions.where("\"katashikiCd\" >= ?", params[:katashikiCdFrom].to_i) if params[:katashikiCdFrom] != ""
conditions = conditions.where("\"katashikiCd\" <= ?", params[:katashikiCdTo].to_i) if params[:katashikiCdTo] != ""
conditions = conditions.where("\"katashikiNm\" LIKE ?", params[:katashikiNm] + "%") if params[:katashikiNm] != ""
logger.debug(conditions)
records = conditions.count
limit = params[:rows].to_i
page = params[:page].to_i
if records > 0
n = records.quo(limit)
total_pages = n.ceil
else
total_pages = 0
end
# 検索開始
start = limit * page - limit;
@kanseiBuhins = conditions.find(
:all,
:offset => start,
:limit => limit,
:order => "\"buhinCd\"")
# 値の格納
@responce = {
total: total_pages.to_s,
page: params[:page],
records: records.to_s,
rows: @kanseiBuhins
}
#logger.debug(@responce)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @responce }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def condicion_search(pparams, phash, pmodel)\n cp = 0\n pv = 0\n cad = ' '\n\n pparams.each do |k,v|\n if (k != 'utf8' and k != 'action' and k != 'controller' and k != 'srchmodel' and k != 'page') \n\t\n\t if v.rstrip != ''\n\t\t\n\t \tif pv > 0\n\t\t\tcad += \" AND \"\n\t\tend\n\t\t\n\t\tif k.to_s == \... | [
"0.7197508",
"0.7154766",
"0.7128347",
"0.66906446",
"0.6652284",
"0.6590838",
"0.6584998",
"0.65368295",
"0.6529783",
"0.64963645",
"0.64767474",
"0.6461192",
"0.64584184",
"0.64435095",
"0.6378344",
"0.63622606",
"0.6336679",
"0.63351846",
"0.63103896",
"0.630408",
"0.63023... | 0.67663586 | 3 |
Strips down a string to only regex [09]. Bang method. Replaces in place. | def strip_numbers!(phone_number)
phone_number.replace(phone_number.scan(NUMBERS_ONLY_REGEX).join)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_with_gsub s\n s.gsub(/\\d[\\d\\s-]+\\d/) do |broad_match|\n masked = nil\n match_from = 0\n mi = 0\n broad_digits = broad_match.scan(/\\d/).map{|v| v.to_i }\n next broad_match if broad_digits.length < 14\n while true\n found, match_start, match_len = iterate(broad_d... | [
"0.62181395",
"0.5844184",
"0.5745595",
"0.5744678",
"0.56577194",
"0.5624906",
"0.559134",
"0.55723304",
"0.55545276",
"0.55288786",
"0.5519982",
"0.5513152",
"0.55078536",
"0.5496632",
"0.54901123",
"0.54710954",
"0.53745997",
"0.5371303",
"0.53585887",
"0.5350577",
"0.5339... | 0.0 | -1 |
Removes the leading 1 for all phones if it's exactly 11 digits loing. Bang method. Replaces in place. | def remove_leading_one!(phone_number)
return phone_number if phone_number.first != '1' # country code is applicable here
return phone_number if phone_number.size != MIN_PHONE_DIGITS + 1
phone_number.replace(phone_number.slice(1..-1))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phone_number_cleaner!\n @phone_number = @phone_number.gsub(/[^0-9]/, '')\n if @phone_number.to_s.size == 11 && @phone_number[0] == '1'\n @phone_number[0] = ''\n end\n end",
"def phone_number_cleaner!\n @phone_number = @phone_number.gsub(/[^0-9]/, '')\n if @p... | [
"0.85953337",
"0.85953337",
"0.8162959",
"0.800507",
"0.77260906",
"0.75588286",
"0.7555583",
"0.75549054",
"0.74827176",
"0.7363044",
"0.736168",
"0.73244566",
"0.7323565",
"0.7160388",
"0.71550757",
"0.71550757",
"0.71550757",
"0.71550757",
"0.7136527",
"0.71287763",
"0.712... | 0.7833245 | 4 |
=== Params band data from facebook | def initialize(fb_data)
@data = fb_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_facebook_params\n\n @fb_details = request.env['omniauth.auth']\n redirect_to main_app.root_path if @fb_details.nil?\n\n @fb_data = Hash.new\n @fb_data[:email] = @fb_details[:info][:email]\n @fb_data[:firstname] = @fb_details[:info][:first_name]\n @fb_data[:lastname] = @fb_details[:info... | [
"0.6691618",
"0.66585964",
"0.6610425",
"0.626983",
"0.604189",
"0.59440887",
"0.593055",
"0.5708242",
"0.5630635",
"0.5604987",
"0.5574742",
"0.5546162",
"0.5528427",
"0.5517001",
"0.5504377",
"0.54545367",
"0.5438522",
"0.54376763",
"0.54292977",
"0.5410506",
"0.5410479",
... | 0.62549525 | 4 |
Replace this with your real tests. | def test_index
get :index
assert_redirected_to :action => :unread
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def __dummy_test__\n end",
"def tests; end",
"def tests; end",
"def spec; end",
"def spec; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test_0_dummy\n\t\tend",
"def test\n\n end",
"def test\n end",
"def test\n end"... | [
"0.7446459",
"0.6956364",
"0.69155836",
"0.69155836",
"0.6864151",
"0.6864151",
"0.66406286",
"0.66406286",
"0.66253287",
"0.6547665",
"0.6524571",
"0.6484549",
"0.6484549",
"0.6484549",
"0.6403847",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188"... | 0.0 | -1 |
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order | def two_sum(nums, target)
results = []
i = 1
while i < nums.length
diff = target - nums[i - 1]
if nums[i..-1].include?(diff)
idx = nums[i..-1].index(diff)
results << i - 1 << idx + i
end
i += 1
end
results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend",
"def two_sum(nums, target)\n target_indexes = []\n nums.each_with_index do |primary, index|\n nums.each_with_index do |num... | [
"0.8469521",
"0.8345762",
"0.8170959",
"0.8127601",
"0.8094328",
"0.8083254",
"0.8068672",
"0.80654836",
"0.8061751",
"0.80270284",
"0.802096",
"0.8012801",
"0.79951936",
"0.7922442",
"0.7844856",
"0.78387135",
"0.78380305",
"0.7817525",
"0.7815674",
"0.7802654",
"0.7791424",... | 0.8027025 | 10 |
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array nums = [1,1,2], Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the new length. | def remove_duplicates(nums)
puts nums.uniq.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_duplicates(array)\n array.uniq!.length\nend",
"def remove_duplicates(nums)\n nums.uniq!\n return nums.length\nend",
"def remove_duplicates(nums)\n \n return nums.length if nums.length <= 2\n prevNum = nums[0]\n i = 1\n arrLength = 1\n dupCount = 1\n while i<nums.length do\n ... | [
"0.81445193",
"0.8112996",
"0.80812114",
"0.79461664",
"0.79412156",
"0.777696",
"0.7505186",
"0.7496743",
"0.748819",
"0.7428481",
"0.73848355",
"0.7253261",
"0.7252629",
"0.72295797",
"0.72220105",
"0.71497345",
"0.7133866",
"0.70874065",
"0.7063284",
"0.7038074",
"0.699076... | 0.79134953 | 5 |
GET /Usuarios GET /Usuarios.xml | def index
#@usuarios = Usuario.all
#page = params[:page] || 1
@usuarios = Usuario.paginate(:page => @page)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @usuarios }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end",
"def consultar\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml {... | [
"0.73021585",
"0.70639926",
"0.6735613",
"0.6735613",
"0.6735613",
"0.6735613",
"0.6684398",
"0.66683435",
"0.65899605",
"0.65819114",
"0.6577307",
"0.6529751",
"0.6484165",
"0.64837134",
"0.6454394",
"0.64210975",
"0.6419777",
"0.63922936",
"0.63922936",
"0.63922936",
"0.638... | 0.65648806 | 11 |
GET /Usuarios/1 GET /Usuarios/1.xml | def show
@usuario = Usuario.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @usuario }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consultar\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end",
"def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { ... | [
"0.71564305",
"0.7068489",
"0.68983924",
"0.66170865",
"0.65848947",
"0.655138",
"0.6469004",
"0.64490056",
"0.64334446",
"0.64007115",
"0.63813037",
"0.6359671",
"0.6356015",
"0.6328953",
"0.63271487",
"0.63187784",
"0.6317044",
"0.6316614",
"0.63092715",
"0.6301768",
"0.630... | 0.696614 | 5 |
GET /Usuarios/new GET /Usuarios/new.xml | def new
@usuario = Usuario.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @Usuario }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end",
"def new\n @usuario = Usuario.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuari... | [
"0.78100944",
"0.7808233",
"0.7516867",
"0.74601316",
"0.7353873",
"0.7249681",
"0.72443676",
"0.7241218",
"0.7232326",
"0.719911",
"0.718034",
"0.7164125",
"0.715564",
"0.71519",
"0.71356744",
"0.711975",
"0.71000934",
"0.7088865",
"0.7082989",
"0.7064895",
"0.70586395",
"... | 0.7743075 | 2 |
POST /Usuarios POST /Usuarios.xml | def create
@usuario = Usuario.new(params[:usuario])
respond_to do |format|
if @usuario.save
flash[:notice] = 'El usuario fue creado exitosamente.'
format.html { redirect_to(@usuario) }
format.xml { render :xml => @usuario, :status => :created, :location => @usuario }
else
format.html { render :action => "new" }
format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @usuario = Usuario.new(params[:usuario])\n\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to(@usuario, :notice => 'Usuario was successfully created.') }\n format.xml { render :xml => @usuario, :status => :created, :location => @usuario }\n else\n ... | [
"0.6311256",
"0.6203309",
"0.60940516",
"0.60911393",
"0.6077686",
"0.5884882",
"0.58649623",
"0.5835982",
"0.5816953",
"0.5807218",
"0.5806025",
"0.5801915",
"0.5763034",
"0.57545894",
"0.57542616",
"0.56984437",
"0.5691789",
"0.5691789",
"0.5691789",
"0.568871",
"0.5676997"... | 0.629725 | 1 |
PUT /Usuarios/1 PUT /Usuarios/1.xml | def update
@usuario = Usuario.find(params[:id])
respond_to do |format|
if @usuario.update_attributes(params[:usuario])
flash[:notice] = 'El usuario fue correctamente actualizado.'
format.html { redirect_to(@usuario) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to(@usuario, :notice => 'Usuario was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :actio... | [
"0.6400291",
"0.6345927",
"0.628902",
"0.6155422",
"0.6151271",
"0.6124549",
"0.61086804",
"0.61059177",
"0.6025157",
"0.6007945",
"0.59239113",
"0.59172136",
"0.5909498",
"0.5881531",
"0.58777416",
"0.5872825",
"0.58191544",
"0.5815104",
"0.58147043",
"0.57693124",
"0.575515... | 0.63276196 | 2 |
Edita su propio perfil | def edit_perfil
usuario = current_user
if usuario
@usuario = usuario
else
redirect_to "/login"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n @profile = current_user.profile\n if @profile.update(profile_params)\n format.html { redirect_to '/home', notice: 'El perfil fue actualizado correctamente.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n\n ... | [
"0.6871978",
"0.6794184",
"0.6760972",
"0.6755883",
"0.6722978",
"0.6722978",
"0.6722978",
"0.6701428",
"0.6701428",
"0.66975266",
"0.6689876",
"0.6688541",
"0.66482794",
"0.66226023",
"0.66131467",
"0.6591996",
"0.6584015",
"0.6578821",
"0.6578821",
"0.6559463",
"0.6555132",... | 0.784805 | 0 |
DELETE /Usuarios/1 DELETE /Usuarios/1.xml | def destroy
@usuario = Usuario.find(params[:id])
@usuario.destroy
respond_to do |format|
format.html { redirect_to(usuarios_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n \n respond_to do |format|\n format.html { redirect_to(usuarios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @usuario = User.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\... | [
"0.7009377",
"0.6871756",
"0.68001074",
"0.6761291",
"0.675707",
"0.6689866",
"0.66161466",
"0.66031694",
"0.65943724",
"0.65774703",
"0.65436023",
"0.65424806",
"0.65422106",
"0.653701",
"0.65227693",
"0.64962584",
"0.64786017",
"0.64782435",
"0.6469047",
"0.64674574",
"0.64... | 0.6994028 | 4 |
sum the rating from user, the higher the better | def popularity(movie_id)
sum=0
@database.each do |key,info_list|
info_list.each do |info|
if info[0].to_i==movie_id.to_i
sum+=info[1].to_i
end
end
end
return sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_ratings\n @sum_ratings ||= @user_ratings.map(&:rating).inject(&:+).to_f\n end",
"def rating\n if self.rating_sum > 0 && self.rating_count > 0\n (self.rating_sum / self.rating_count).round(2)\n end\n end",
"def user_average_rating(user)\n #av = promedio (avarage), counter = contador(p... | [
"0.82106996",
"0.785109",
"0.7656369",
"0.7499054",
"0.74924666",
"0.7483474",
"0.74779737",
"0.7477552",
"0.7429877",
"0.74095714",
"0.74030876",
"0.7397913",
"0.73597044",
"0.73560184",
"0.7336137",
"0.7327783",
"0.73242056",
"0.7309712",
"0.73081475",
"0.7255266",
"0.72453... | 0.0 | -1 |
allow account update without specifying your password | def update_resource(resource, params)
resource.update_without_password(params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_with_password(params, *options); end",
"def update_without_password(params, *options); end",
"def edit_password; end",
"def update!(**args)\n @password = args[:password] if args.key?(:password)\n @user = args[:user] if args.key?(:user)\n end",
"def change_password\r\n ... | [
"0.7831725",
"0.7497459",
"0.72468054",
"0.7224611",
"0.7194428",
"0.7092168",
"0.70557415",
"0.7048837",
"0.70218796",
"0.700996",
"0.70029974",
"0.69978625",
"0.69822365",
"0.6945035",
"0.6937411",
"0.6937283",
"0.6934329",
"0.6925068",
"0.6911283",
"0.6910967",
"0.6910967"... | 0.0 | -1 |
Allow for creation of 5 ShortenedUrls per minute max | def no_spamming
created_urls = submitter.submitted_urls
num_of_recent_urls = created_urls
.where('created_at > ?', 1.minute.ago)
.count
raise "Cannot create more than 5 shortened links in a minute!" if num_of_recent_urls >= 5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_short_url\n random_chars = ['0'..'9','A'..'Z','a'..'z'].map{|range| range.to_a}.flatten\n self.assign_attributes(short_url: 6.times.map{ random_chars.sample }.join.prepend(\"http://\")) until self.short_url.present? && Link.find_by_short_url(short_url).nil?\n end",
"def create_short_url\n ... | [
"0.71524715",
"0.6944787",
"0.6916518",
"0.6914879",
"0.6834846",
"0.68155485",
"0.676827",
"0.67620516",
"0.67620516",
"0.6726566",
"0.66728175",
"0.66568184",
"0.6641456",
"0.6625504",
"0.66180533",
"0.65875334",
"0.6507626",
"0.6500213",
"0.6497644",
"0.6475199",
"0.646602... | 0.69650996 | 1 |
Limit nonpremium users to creating 5 ShortenedUrls max | def nonpremium_max
return nil if submitter.premium
created_urls = submitter.submitted_urls
raise "Non-premium accounts are limited to 5 Shortened URLs per user" if created_urls.count >= 5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_spamming\n created_urls = submitter.submitted_urls\n num_of_recent_urls = created_urls\n .where('created_at > ?', 1.minute.ago)\n .count\n\n raise \"Cannot create more than 5 shortened links in a minute!\" if num_of_recent_urls >= 5 \n end",
"def no_spamming\n cnt = user\n ... | [
"0.6934241",
"0.6458169",
"0.6436229",
"0.63092214",
"0.63092214",
"0.627229",
"0.6268417",
"0.62402046",
"0.6187315",
"0.6138328",
"0.6096861",
"0.6069791",
"0.6068162",
"0.60563904",
"0.60221416",
"0.6015275",
"0.5949638",
"0.58199316",
"0.5803775",
"0.57888997",
"0.5775395... | 0.8482006 | 0 |
Are notes in the same graph? | def notes_in_the_same_graph?
if self.source_note.nil?
return false
end
if self.target_note.nil?
return false
end
return self.source_note.graph == self.target_note.graph
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def different_notes?\n if self.source_note.nil?\n return false\n end\n if self.target_note.nil?\n return false\n end\n return self.source_note != self.target_note\n end",
"def equivalent?(other_chord)\n other_notes = other_chord.notes.map(&:unbind)\n notes.uniq.sort == other_n... | [
"0.6654293",
"0.61116856",
"0.59113777",
"0.58173233",
"0.58132035",
"0.5663675",
"0.563164",
"0.5607588",
"0.5603544",
"0.5603544",
"0.5603544",
"0.56011367",
"0.56010455",
"0.55668646",
"0.55227923",
"0.5516326",
"0.55051094",
"0.54770356",
"0.5458376",
"0.54555386",
"0.544... | 0.7899092 | 0 |
Are notes different? As in, not the same note. (Properties besides ID can be the same, of course) | def different_notes?
if self.source_note.nil?
return false
end
if self.target_note.nil?
return false
end
return self.source_note != self.target_note
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eql?(other_note)\n other_note.instance_of?(self.class) and self == other_note\n end",
"def ==(other_note)\n self.tone == other_note.tone\n end",
"def notes_in_the_same_graph?\n if self.source_note.nil? \n return false\n end\n if self.target_note.nil? \n return false\n ... | [
"0.63706565",
"0.63424486",
"0.62246",
"0.619334",
"0.6150781",
"0.6105678",
"0.6098882",
"0.60767806",
"0.6075602",
"0.6073008",
"0.5900267",
"0.5883932",
"0.5877974",
"0.5853289",
"0.5794233",
"0.57785225",
"0.57640356",
"0.57606083",
"0.5746181",
"0.57453763",
"0.5742036",... | 0.7353027 | 0 |
Is there already a note from target to source? | def bidirectionally_unique?
if self.source_note.nil?
return false
end
if self.target_note.nil?
return false
end
return Edge.first(:conditions => {:source_id => self.target_note.id, :target_id => self.source_note.id}).nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def different_notes?\n if self.source_note.nil?\n return false\n end\n if self.target_note.nil?\n return false\n end\n return self.source_note != self.target_note\n end",
"def orphan?\n !target_type || !notes.match?(/\\A\\d{14}/)\n end",
"def notes_in_the_same_graph?\n if self.... | [
"0.6855658",
"0.6619958",
"0.6479083",
"0.642819",
"0.6127064",
"0.6036958",
"0.6023684",
"0.5915764",
"0.5810275",
"0.5795451",
"0.57939565",
"0.5782486",
"0.5741669",
"0.57402575",
"0.5712923",
"0.5705824",
"0.56656635",
"0.5661356",
"0.5636952",
"0.56108403",
"0.5606577",
... | 0.6392804 | 4 |
Run on guide and returns report | def run
report = "Seriously::#{params[:id].to_s.classify}Guide::Base".constantize.run(verbose: false)
render json: report
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report\n \n end",
"def report\n\t\tend",
"def execute\n puts @robot.report\n end",
"def report(output)\n end",
"def run\n @report = Report.new\n @report.plugin = self\n bui... | [
"0.7354263",
"0.7354263",
"0.7354263",
"0.7354263",
"0.7354263",
"0.72990054",
"0.70978945",
"0.6788482",
"0.67505884",
"0.65277207",
"0.65267944",
"0.6518355",
"0.6516559",
"0.65113986",
"0.6448719",
"0.64310515",
"0.63754135",
"0.6364535",
"0.6303359",
"0.62592494",
"0.6221... | 0.62160885 | 23 |
TODO: lots of this stuff is specific to a decision tree. | def initialize(relation_name, attributes, data, class_attribute)
@relation_name = relation_name
@attributes = attributes
@data = data
@class_attribute = class_attribute
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decision_tree_class\n C100App::CompletionDecisionTree\n end",
"def parsed_tree; end",
"def decision\n return @decision\n end",
"def render_decision args\n decision = current_decision args\n # text is either the value of decision's description key or warning that no des... | [
"0.597345",
"0.5909468",
"0.5878644",
"0.5855606",
"0.5774286",
"0.5757316",
"0.56772333",
"0.5663579",
"0.563308",
"0.56110203",
"0.56110203",
"0.5577041",
"0.5576192",
"0.55466545",
"0.5500676",
"0.54962397",
"0.5473831",
"0.5467606",
"0.54351884",
"0.542709",
"0.53875214",... | 0.0 | -1 |
Make all continuous attributes discrete | def continuize!
@data.each_index do |data_index|
@data[data_index].each do |attribute_name, attribute|
att_type = @attributes.find { |attr| attr[:name] == attribute_name }
#class is a special case. Store original value
if att_type[:name] == "class" or att_type[:name] == @class_attribute
@old_class_nominal_attributes = att_type[:nominal_attributes]
end
if att_type[:type] == "string" or att_type[:type] == "nominal"
@data[data_index][attribute_name] = att_type[:nominal_attributes].find_index(attribute)
end
end
end
#change attribute types
@attributes.each do |attribute|
if attribute[:type] == "string" or attribute[:type] == "nominal"
attribute[:type] = "numeric"
attribute[:old_nominal_attributes] = attribute[:nominal_attributes]
attribute[:nominal_attributes] = nil
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discrete_set(v)\n sig_val = sigmoid(v)\n ret = if sig_val <= 0.25\n -1\n elsif sig_val >= 0.75\n 1\n else\n 0\n end\n end",
"def discrete\n\n height = @options[:height].to_f\n upper = normalize(@options[:upper].to_f)\n background_color = @options[:bac... | [
"0.5701719",
"0.5652055",
"0.53836375",
"0.5226976",
"0.48273346",
"0.4741695",
"0.46655294",
"0.4654857",
"0.46285343",
"0.46129662",
"0.45786908",
"0.45717704",
"0.44770524",
"0.44707528",
"0.44695765",
"0.44608656",
"0.4457269",
"0.44568703",
"0.4446897",
"0.4440583",
"0.4... | 0.49085897 | 4 |
Return an array of new ArffFile objects split on the given attribute | def split_on_attribute(attribute)
index = find_index_of_attribute(attribute)
splitted_stuff = {}
@attributes[index][:nominal_attributes].each do |attribute_value|
splitted_stuff[attribute_value] = []
end
#then remove that attribute?
@data.each do |data|
splitted_stuff[data[attribute]] << data.clone
end
ret = {}
splitted_stuff.each do |key, value|
ret[key] = ArffFile.new(@relation_name.clone, @attributes.clone, value.clone, @class_attribute.clone).remove_attribute(attribute)
end
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve(attribute)\n attributes = []\n @files.each do |file|\n attributes.push(file[attribute.to_s]) if file[attribute.to_s].present?\n end\n attributes\n end",
"def split() File.split(@path).map {|f| self.class.new(f) } end",
"def get\n arr = []\n\n process(csv_fil... | [
"0.61262554",
"0.6109307",
"0.5442131",
"0.52961385",
"0.5243283",
"0.5243283",
"0.5139335",
"0.51194966",
"0.5090329",
"0.50429493",
"0.5019851",
"0.49869454",
"0.4959345",
"0.49237558",
"0.49090505",
"0.48791775",
"0.486143",
"0.48350227",
"0.48311663",
"0.48238683",
"0.481... | 0.70536923 | 0 |
Removes an attribute from a dataset. to_remove can be an index or a String or symbol for the attribute name. | def remove_attribute(to_remove)
index = 0
if not to_remove.kind_of? Fixnum
index = find_index_of_attribute(to_remove)
else
index = to_remove
end
# binding.pry
if not index.nil?
@attributes.delete_at index
@data.each do |d|
d.delete to_remove
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def remove_attribute(name); end",
"def - (name) remove_attribute name end",
"def remove_attr(name); end",
"def remove_attr(name); end",
"def remove_attribute(attr)\n C.LLVMRemoveFunctionAttr... | [
"0.6693441",
"0.6693441",
"0.6693441",
"0.6693441",
"0.65489346",
"0.6396487",
"0.6396487",
"0.6213663",
"0.6179488",
"0.6122835",
"0.60458183",
"0.59947646",
"0.596605",
"0.5939172",
"0.592752",
"0.5918795",
"0.58605015",
"0.585825",
"0.585825",
"0.58464295",
"0.5841614",
... | 0.7978585 | 0 |
default logger format, removes prompt of: +d, [20200620 14:02:2917329] INFO MONGODB:+ | def format!(logger)
logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_logger\n logger = Logger.new(STDERR)\n logger.level = Mongoid::Config.log_level\n logger\n end",
"def log(level, msg)\n return unless @logger\n case level\n when :fatal then\n @logger.fatal \"MONGODB [FATAL] #{msg}\"\n when :error then\n @lo... | [
"0.6554253",
"0.63158906",
"0.61414135",
"0.606089",
"0.606089",
"0.60294485",
"0.5886083",
"0.5875358",
"0.5851266",
"0.5831013",
"0.5821225",
"0.5811389",
"0.5788149",
"0.5788149",
"0.57853806",
"0.5772454",
"0.5754078",
"0.5710082",
"0.56836396",
"0.56511915",
"0.5649197",... | 0.5763558 | 16 |
checks if a message if a message is included in the +UNNECESSARY+ array constant | def unnecessary?(msg)
UNNECESSARY.any? { |s| msg.downcase.include? s }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include?(hint)\n (v = messages[hint]) && v.any?\n end",
"def include?(error)\n (v = messages[error]) && v.any?\n end",
"def check_key(key, array)\n return true if ![nil, '', '-'].include?(array[key])\n raise RuntimeError, \"#{key} is empty\"\n end",
"def msg_exists(msg)... | [
"0.6057573",
"0.5822726",
"0.57911474",
"0.5776648",
"0.57605225",
"0.5666967",
"0.56531197",
"0.5646304",
"0.5641864",
"0.5624863",
"0.56123346",
"0.55909103",
"0.55693555",
"0.55274177",
"0.5518616",
"0.5515986",
"0.54583704",
"0.54120874",
"0.5407269",
"0.54070616",
"0.537... | 0.6494653 | 0 |
takes a log message and returns the message formatted | def format_log(msg)
msg = colorize_log(msg)
msg = remove_prefix(msg)
"#{msg}\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_log_message(msg)\n \"[Cloudtasker/Server][#{id}] #{msg}\"\n end",
"def format_message(severity, timestamp, progname, msg)\n \"#{AUTHORIZATION_SYSTEM_LOG_MSG_PREFIX} #{timestamp.to_formatted_s(:db)} #{severity} #{msg}\\n\" \n end",
"def format_log_message file, lineno, line, paramet... | [
"0.7287236",
"0.72169155",
"0.7044046",
"0.6987145",
"0.68418026",
"0.6765429",
"0.67498034",
"0.6730842",
"0.6724308",
"0.67067987",
"0.6705526",
"0.6690692",
"0.666397",
"0.66603094",
"0.66213804",
"0.6608459",
"0.6568617",
"0.6529895",
"0.65196097",
"0.64855164",
"0.647237... | 0.77879244 | 0 |
colorize messages that are specified in ACTIONS constant | def colorize_log(msg)
ACTIONS.each { |a| msg = color(msg, a[:color]) if msg.downcase.include?(a[:match]) }
return msg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_formatted_action(msg, opts={})\n m = [self.timestamp] + msg\n\n unless opts[:no_truncate]\n if m.map(&:first).join(' ').length > self.term_width\n fixed_length = m[0,2].map(&:first).join(' ').length\n m[2][0] = m[2][0][0,(term_width - fixed_length - 4)] + ' … '\n ... | [
"0.6814007",
"0.651351",
"0.64046085",
"0.63501096",
"0.62814885",
"0.6226943",
"0.60223216",
"0.5982107",
"0.59337145",
"0.59144056",
"0.58934546",
"0.5865128",
"0.5863261",
"0.5855968",
"0.5854905",
"0.58496714",
"0.58496714",
"0.5847925",
"0.5846873",
"0.5845119",
"0.58409... | 0.8019794 | 0 |
remove prefix defined in +PREFIX_REGEX+ from message | def remove_prefix(msg)
msg.sub(PREFIX_REGEX, "|")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_prefix(name)\n name.sub /^[xX][rR](_?)/, \"\"\nend",
"def strip_prefix(str, prefix)\n str.start_with?(prefix) ? str.slice(prefix.length..-1) : str\n end",
"def remove_prefix!(string)\n string.gsub!(\"#{VM_PREFIX}_\", '')\n string.gsub!(VM_PREFIX, '')\nend",
"def strip_prefix(string)\... | [
"0.6854396",
"0.67723227",
"0.66307056",
"0.6620254",
"0.6306731",
"0.62043434",
"0.6190567",
"0.6183674",
"0.6120959",
"0.61186594",
"0.60173446",
"0.60004866",
"0.5987845",
"0.5985826",
"0.5896774",
"0.584607",
"0.5818836",
"0.5769092",
"0.57543695",
"0.57396597",
"0.571925... | 0.8711799 | 0 |
send all other methods back to logger instance | def method_missing(method, *args, &block)
@targets.each { |t| t.send(method, *args, &block) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method_missing(m, *args, &block)\n \tRails.logger.send m, *args, &block\n end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logge... | [
"0.69424206",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.6931033",
"0.69254184",
... | 0.0 | -1 |
set color based one the defined constants. If a third option is set to +true+, the string will be made bold. CLEAR to the is automatically appended to the string for reset | def color(text, color, bold = false)
bold = bold ? BOLD : ""
"#{bold}#{color}#{text}#{CLEAR}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cyan; if @options[:colors]; \"\\e[1;36m\" else \"\" end end",
"def color(text, color)\n if COLORS[color]\n \"#{start_color color}#{text}#{reset_color}\"\n end\n end",
"def color(text, color, mode_options = {}) # :doc:\n return text unless colorize_logging\n color = se... | [
"0.6677382",
"0.6523837",
"0.64401305",
"0.6429064",
"0.6332658",
"0.6314553",
"0.62296116",
"0.6217173",
"0.6187157",
"0.61654097",
"0.61489826",
"0.61371535",
"0.61299527",
"0.61029667",
"0.60989356",
"0.6089932",
"0.60790133",
"0.60770655",
"0.60742164",
"0.60416317",
"0.6... | 0.71913946 | 0 |
Used when the validation_hint is optional | def has_validation_hint?
validation_hint.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validation_default; false; end",
"def validation_default; true; end",
"def validation_default; true; end",
"def validation\n # Rails.logger.debug \"#{self.class}.#{__method__} Default validator is empty\"\n end",
"def validation_context\n {}\n end",
"def validated?; end",
"def has_required?... | [
"0.70188755",
"0.7011366",
"0.7011366",
"0.6994977",
"0.69183826",
"0.6731706",
"0.6680499",
"0.66651666",
"0.6631223",
"0.6631223",
"0.6576727",
"0.6568121",
"0.65278417",
"0.65278417",
"0.65068513",
"0.64715475",
"0.6469731",
"0.6444738",
"0.6433472",
"0.64201564",
"0.63761... | 0.7436239 | 0 |
makes sure the same user can't make multiple offers to the same trade | def trade_is_not_a_repeat
# see if the record has been created, and has an id assigned
number_that_can_exist = id.nil? ? 0 : 1
if Offer.where(user_id: user_id, trade_id: trade_id).length > number_that_can_exist
errors.add(:user_id, "user has already made an offer for this trade")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_sure_no_duplicate_offers\n other_offer = self.sender.active_offer_between_user_for_textbook(self.reciever_id, self.textbook_id)\n\n if other_offer.nil?\n if self.listing.nil?\n\t if self.selling?\n self.errors.add(:reciever_id, \"You don't have a current listing 'For Sale' for... | [
"0.6968255",
"0.6415409",
"0.6087627",
"0.588009",
"0.5879429",
"0.5853544",
"0.58353084",
"0.5822977",
"0.5810023",
"0.5779928",
"0.57678455",
"0.57532203",
"0.57504547",
"0.5744216",
"0.57348293",
"0.573474",
"0.573332",
"0.5725953",
"0.5718551",
"0.5717363",
"0.5712558",
... | 0.72359073 | 0 |
makes sure a trade is open to offers before creating an offer | def trade_is_open
unless trade && trade.status == Trade::STATUSES['open']
errors.add(:trade_id, "Offers cannot be made unless the trade is open.")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n flag = true\n item = Item.find(params[:trades][:item_id])\n offer = Item.find(params[:trades][:offer_id])\n passive_trade = PassiveTrade.find(params[:trades][:passive_trade_id])\n if !item.live? or !offer.live? \n flag = false\n end\n t = Trade.where(:item_id => item.id, :off... | [
"0.6683461",
"0.6553436",
"0.6346874",
"0.6118842",
"0.6109499",
"0.61002755",
"0.60825926",
"0.60546196",
"0.60336137",
"0.60102606",
"0.59325975",
"0.59066606",
"0.59035206",
"0.5885251",
"0.58825547",
"0.5834772",
"0.5830133",
"0.58266807",
"0.58033866",
"0.5790515",
"0.57... | 0.7134383 | 0 |
makes sure only offers for the same console are valid | def user_on_same_console
if user.nil? || trade.nil? || user.console != trade.user.console
errors.add(:trade_id, "Trade must be for the same console")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_sure_no_duplicate_offers\n other_offer = self.sender.active_offer_between_user_for_textbook(self.reciever_id, self.textbook_id)\n\n if other_offer.nil?\n if self.listing.nil?\n\t if self.selling?\n self.errors.add(:reciever_id, \"You don't have a current listing 'For Sale' for... | [
"0.5410934",
"0.53471756",
"0.5341136",
"0.52424496",
"0.52302974",
"0.5222446",
"0.52153146",
"0.521421",
"0.521421",
"0.5209314",
"0.52080786",
"0.51929",
"0.51927453",
"0.5164153",
"0.51550186",
"0.5149486",
"0.5148308",
"0.51479167",
"0.5146003",
"0.5129076",
"0.51114374"... | 0.5532448 | 0 |
comment_block() outputs a standard Ruby comment block | def comment_block( *lines )
self.blank_line
self << %[#]
self.indent( "# " ) do
lines.each do |line|
self << line unless line.nil?
end
yield( self ) if block_given?
end
self.blank_line
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment( text = nil, &block )\n make_indent if @indent > 0\n \n @serial = @serial + 1\n @buffer << \"<!-- \"\n \n if text then \n @buffer << encode(text)\n elsif !block.nil? then\n capture(&block)\n end\n \n @buffer << \" -->\"\n end",
"def ... | [
"0.7728243",
"0.7457021",
"0.7457021",
"0.7337075",
"0.7316744",
"0.72572887",
"0.72345114",
"0.7163429",
"0.7018599",
"0.6997021",
"0.6969774",
"0.6969774",
"0.6937527",
"0.6934137",
"0.6934137",
"0.6934137",
"0.6934137",
"0.6904793",
"0.6896777",
"0.6859331",
"0.6762318",
... | 0.72168124 | 7 |
Methods to use in controller..... to create a post we have to get the current user, and the profile he is viewing | def create_post(user, friend, text)
UserPost.create(text: text,user1_id: user, user2_id: friend)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @post = Post.new(post_params)\n @post.user = current_user\n @post.save\n redirect_to @post\n\n end",
"def create\n #Only the loged user can create posts for himself, not any other user.\n @post = @user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n ... | [
"0.7547521",
"0.74981743",
"0.7492395",
"0.74666756",
"0.7450499",
"0.7441316",
"0.7438933",
"0.7397327",
"0.7386466",
"0.7377027",
"0.73741335",
"0.73680305",
"0.7321365",
"0.7320688",
"0.7309966",
"0.7309249",
"0.730487",
"0.7288179",
"0.72781616",
"0.72560495",
"0.72418684... | 0.0 | -1 |
to view a post we have to get the current user, and the profile he is viewing | def view(user, friend)
post = UserPost.where(user1_id: user, user2_id: friend)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @post = Post.find(params[:id])\n @user = current_user\n end",
"def show\n @user = User.find(@post.user_id)\n end",
"def show\n @post = Post.new\n @user = User.find params[:id]\n @posts = Post.where(\"user_id = ?\", @user[:id])\n @title = \"Profile: \" + @user.username\n end",... | [
"0.78440815",
"0.779411",
"0.76547605",
"0.7480559",
"0.7429356",
"0.73974055",
"0.7320419",
"0.7287811",
"0.72701865",
"0.7260165",
"0.7229102",
"0.7225554",
"0.72161406",
"0.72145724",
"0.7202835",
"0.71353114",
"0.71238047",
"0.70719504",
"0.7069117",
"0.70279247",
"0.7027... | 0.67613053 | 43 |
redefine your position_taken? method here, so that you can use it in the valid_move? method above. | def position_taken?(board, idx)
["X", "O"].include?(board[idx])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v... | [
"0.84089375",
"0.8162548",
"0.80914116",
"0.8028049",
"0.8014509",
"0.7898257",
"0.78943205",
"0.78863996",
"0.78445494",
"0.78427726",
"0.78322136",
"0.78148186",
"0.78134465",
"0.7810213",
"0.7802794",
"0.78019965",
"0.78009653",
"0.77892697",
"0.7782964",
"0.777476",
"0.77... | 0.0 | -1 |
Now extend the Array class to include my_select that takes a block and returns a new array containing only elements that satisfy the block. Use your my_each method! | def my_select(&prc)
selection = []
i = 0
while i < self.length
if prc.call(self[i])
selection << self[i]
end
i += 1
end
return selection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_select\n new_arr = []\n self.my_each do |ele|\n new_arr << ele if yield ele\n end\n new_arr\n end",
"def my_select\n arr = []\n self.my_each {|x| arr << x if yield x}\n arr\n end",
"def my_select(&block)\n result = []\n my_each do |elem|\n result << elem if block.c... | [
"0.84452134",
"0.83266735",
"0.8278081",
"0.8233434",
"0.81102276",
"0.8094788",
"0.8029384",
"0.7981806",
"0.7887911",
"0.78706664",
"0.7844753",
"0.7842753",
"0.77930135",
"0.7710922",
"0.77061504",
"0.7697411",
"0.7643738",
"0.76163954",
"0.7581148",
"0.75727606",
"0.75391... | 0.6798151 | 42 |
Write my_reject to take a block and return a new array excluding elements that satisfy the block. | def my_reject(&prc)
rejection = []
i = 0
while i < self.length
if !prc.call(self[i])
rejection << self[i]
end
i += 1
end
return rejection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_reject(&prc)\n\t\tnew_array = []\n\n\t\tself.my_each do |ele|\n\t\t\tnew_array << ele if !prc.call(ele)\t\t\t\t\n\t\tend\n\n\t\tnew_array\n\tend",
"def my_reject(&prc)\n arr = []\n self.my_each { |el| arr << el if !prc.call(el) }\n arr\n end",
"def my_reject(arr,&prc)\n remainde... | [
"0.77882814",
"0.75782925",
"0.7383995",
"0.72468245",
"0.71466064",
"0.7123806",
"0.707463",
"0.70282537",
"0.6974494",
"0.69211",
"0.6898149",
"0.682925",
"0.67519176",
"0.66831",
"0.66273993",
"0.66132087",
"0.6562831",
"0.6556095",
"0.65476376",
"0.65165865",
"0.6472411",... | 0.71689457 | 4 |
Write my_any? to return true if any elements of the array satisfy the block and my_all? to return true only if all elements satisfy the block. | def my_any?(&prc)
i = 0
while i < self.length
if prc.call(self[i]) == true
return true
end
i += 1
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_any?\n all = false\n self.my_each do |x|\n if !block_given?\n if x || !x.nil?\n all = true\n end\n elsif yield x\n all = true\n end\n break if all == true\n end\n all\n end",
"def my_any?(arr, &prc)\n arr.each do |ele|\n return true ... | [
"0.7960906",
"0.7924131",
"0.78736955",
"0.78420866",
"0.7827809",
"0.77741617",
"0.77730644",
"0.776643",
"0.77654076",
"0.7660904",
"0.76324725",
"0.7609725",
"0.7607826",
"0.76056004",
"0.76056004",
"0.75952685",
"0.7568064",
"0.7551117",
"0.75151646",
"0.74255055",
"0.741... | 0.7635935 | 10 |
my_flatten should return all elements of the array into a new, onedimensional array. Hint: use recursion! | def my_flatten
arr = []
i = 0
while i < self.length
if self[i].is_a? Array
arr += self[i].my_flatten
else
arr << self[i]
end
i += 1
end
return arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_flatten\n flattened_array = []\n each do |item|\n if item.class != Array\n flattened_array << item\n else\n #recursevly call my flatten\n item.my_flatten.each { |sub_item| flattened_array << sub_item }\n end\n end\n flattened_array\n end",
"def my_flatten\n... | [
"0.81874835",
"0.80982953",
"0.8023162",
"0.8021197",
"0.7873731",
"0.78402483",
"0.779833",
"0.77438736",
"0.77373993",
"0.7689893",
"0.7689893",
"0.7683187",
"0.76608276",
"0.76396793",
"0.76396793",
"0.76336336",
"0.76336336",
"0.76336336",
"0.76336336",
"0.76336336",
"0.7... | 0.8041758 | 2 |
Write my_zip to take any number of arguments. It should return a new array containing self.length elements. Each element of the new array should be an array with a length of the input arguments + 1 and contain the merged elements at that index. If the size of any argument is less than self, nil is returned for that location. | def my_zip(*arrays)
i = 0
zipped = []
while i < self.length
nest = [self[i]]
arrays.my_each do |arr|
if i < arr.length
nest << arr[i]
else
nest << nil
end
end
zipped << nest
i += 1
end
return zipped
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_zip(*args)\n zipped = Array.new(self.length) {[]}\n\n self.each_with_index { |el, i_arr| zipped[i_arr] << el}\n args.each_with_index do |arg, i_arg|\n (zipped.length).times {|i_arg_el| zipped[i_arg_el] << arg[i_arg_el]}\n end\n zipped\n end",
"def my_zip(*a... | [
"0.7993346",
"0.7171449",
"0.6906811",
"0.68743765",
"0.6857708",
"0.66011566",
"0.65430564",
"0.65390015",
"0.6427724",
"0.6289802",
"0.61811864",
"0.60137665",
"0.6002802",
"0.59019065",
"0.5884806",
"0.584799",
"0.58433497",
"0.5839005",
"0.57678163",
"0.57246906",
"0.5706... | 0.67384714 | 5 |
Write a method my_rotate that returns self rotated. By default, the array should rotate by one element. If a negative value is given, the array is rotated in the opposite direction. | def my_rotate(pos=1)
pos.times do
self.push(self.shift)
end
return self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_rotate(arr)\n print arr.rotate\n end",
"def my_rotate!(array, amt)\n\nend",
"def my_rotate(num = 1)\n num < 1 ? num.abs.times {self.unshift(self.pop)} : num.times {self.push(self.shift)}\n self\n end",
"def my_rotate(num = 1)\n offset = num % self.length\n self.drop(offset) ... | [
"0.7689837",
"0.7450369",
"0.7337929",
"0.7266656",
"0.7196517",
"0.71069294",
"0.7103364",
"0.69522715",
"0.692674",
"0.6794971",
"0.67792004",
"0.6771717",
"0.6771717",
"0.6761561",
"0.67435664",
"0.6717796",
"0.6708353",
"0.6708353",
"0.6708353",
"0.6708353",
"0.6708353",
... | 0.72281665 | 4 |
my_join returns a single string containing all the elements of the array, separated by the given string separator. If no separator is given, an empty string is used. | def my_join(link="")
str = ""
i = 0
while i < self.length
if i != 0
str += link
end
str += self[i].to_s
i += 1
end
return str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_join(array, separator)\n\tarray_string = \" \"\n\tarray.each{ |a| array_string << a + separator }\n\treturn array_string\nend",
"def my_join(arr, separator = \"\")\n str = \"\"\n arr.each_with_index { |el, i| str += el + separator}\n return str[0..separator.length*-1-1]\nend",
"def my_join(arr, separ... | [
"0.88390476",
"0.86078805",
"0.8597715",
"0.85454005",
"0.8535866",
"0.85291773",
"0.84992737",
"0.8493449",
"0.8485974",
"0.84780633",
"0.8409516",
"0.83667535",
"0.8319346",
"0.8314559",
"0.8275135",
"0.81557107",
"0.812804",
"0.8122665",
"0.8086827",
"0.8085121",
"0.808297... | 0.7110448 | 37 |
Write a method that returns a new array containing all the elements of the original array in reverse order. | def my_reverse
reverse = []
i = self.length - 1
while i >= 0
reverse << self[i]
i -= 1
end
return reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_array(array_new)\n array_new.reverse \n end",
"def reverse(array)\n result_array = []\n array.reverse_each { |element| result_array << element }\n result_array\nend",
"def reverse(array)\n result_array = []\n array.reverse_each { |element| result_array << element }\n result_array\nend",... | [
"0.8644121",
"0.8546132",
"0.8546132",
"0.8522452",
"0.84845865",
"0.845157",
"0.8442636",
"0.8401113",
"0.8393306",
"0.8382579",
"0.83584803",
"0.83541095",
"0.83541095",
"0.83541095",
"0.83541095",
"0.83541095",
"0.83541095",
"0.83541095",
"0.83541095",
"0.83541095",
"0.835... | 0.7941648 | 69 |
you can say except or only | def index
#to store cookies, see how many visitors, etc. sessions is a cookie.
# if session[:count] == nil
# session[:count] = 0
# end
# session[:count] +=1
# @counter = session[:count]
@purses = Purse.all
sort_attribute = params[:sort]
order_attribute = params[:sort_order]
discount_amount = params[:discount]
category_sort = params[:category_id]
search_term = params[:search_term]
if category_sort
@purses = Category.find_by(id: category_sort).purses
end
if discount_amount
@purses = @purses.where("price < ?", discount_amount)
end
if sort_attribute && order_attribute
@purses = @purses.order({sort_attribute => order_attribute}) #this makes it more dynamic, lets you type whatever value i.e, desc or asc into the order_attribute search bar, or any sort_attribute . have to break it apart into the hash rocket syntax, otherwise it won't work, as a symbol
elsif sort_attribute
@purses = @purses.order(sort_attribute)
end
if search_term
@purses = @purses.where("name iLIKE ? OR description iLIKE ?", "%#{search_term}%" , "%#{search_term}%" )
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def excluded; end",
"def exclude; end",
"def ignores; end",
"def ignore; end",
"def ignore(*args); end",
"def unless_condition; end",
"def ignored?()\n #This is a stub, used for indexing\n end",
"def exclude=(_arg0); end",
"def allows_not_action\n @statements.select { |statemen... | [
"0.7294366",
"0.7203189",
"0.7167285",
"0.7010639",
"0.67544496",
"0.64616525",
"0.64294875",
"0.6279929",
"0.62302715",
"0.62144935",
"0.6206721",
"0.61943483",
"0.61906326",
"0.6182039",
"0.61771625",
"0.6165924",
"0.6165761",
"0.6162465",
"0.6162464",
"0.6152767",
"0.61506... | 0.0 | -1 |
this is for checkboxes which give us a param of 'on' on the params hash | def normalize
replacements = { 'on' => true, '' => nil}
normalized = {}
self.each_pair do |key,val|
normalized[key] = replacements.has_key?(val) ? replacements[val] : val
end
normalized
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkboxes_for(method,vals,options={})\n \n end",
"def checkboxes; end",
"def checkbox_checked\n return 'checked=checked' if show\n\n ''\n end",
"def check_box; end",
"def build_check_box_without_hidden_field(options); end",
"def switch_params\n params.permit(:is_on)\n end",
"def... | [
"0.7102771",
"0.6825558",
"0.6421961",
"0.63545877",
"0.63206977",
"0.63136536",
"0.62110454",
"0.6167114",
"0.61328566",
"0.6076351",
"0.59995955",
"0.59494317",
"0.593552",
"0.59340125",
"0.59145343",
"0.58546746",
"0.5833506",
"0.5805612",
"0.579222",
"0.5789278",
"0.57651... | 0.0 | -1 |
Returns all policy instances | def get_all_policies
@command = :get_all_policies
raise ProjectHanlon::Error::Slice::SliceCommandParsingFailed,
"Unexpected arguments found in command #{@command} -> #{@command_array.inspect}" if @command_array.length > 0
# get the policies from the RESTful API (as an array of objects)
uri = URI.parse @uri_string
result = hnl_http_get(uri)
unless result.blank?
# convert it to a sorted array of objects (from an array of hashes)
sort_fieldname = 'line_number'
result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname)
end
# and print the result
print_object_array(result, "Policies:", :style => :table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policies\n @policies = Policy.all\n end",
"def find_all_resources options\n policy_scope(resource_class)\n end",
"def index\n @policies = Policy.all\n end",
"def index\n @priv_policies = PrivPolicy.all\n end",
"def policy_classes\n fetch_policies! unless @fetched\n ... | [
"0.7464853",
"0.6737194",
"0.6611847",
"0.6559259",
"0.64755905",
"0.6422424",
"0.6364494",
"0.63396394",
"0.6315466",
"0.62616324",
"0.62502855",
"0.6196983",
"0.61888546",
"0.6140078",
"0.6123789",
"0.6118178",
"0.6107066",
"0.6078124",
"0.60427094",
"0.6039749",
"0.6009159... | 0.5910806 | 35 |
Returns the policy templates available | def get_policy_templates
@command = :get_policy_templates
# get the policy templates from the RESTful API (as an array of objects)
uri = URI.parse @uri_string + '/templates'
result = hnl_http_get(uri)
unless result.blank?
# convert it to a sorted array of objects (from an array of hashes)
sort_fieldname = 'template'
result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname)
end
# and print the result
print_object_array(result, "Policy Templates:", :style => :table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @policy_templates = PolicyTemplate.all\n end",
"def templates\n response = get 'templates'\n response.map{|item| Hashie::Mash.new(item)}\n end",
"def templates\n @templates ||= (\n list = []\n list.concat templates_from_project\n list.concat templa... | [
"0.7061667",
"0.6666429",
"0.665107",
"0.6640467",
"0.65752417",
"0.6467771",
"0.6467769",
"0.6442301",
"0.6428483",
"0.64229816",
"0.6392251",
"0.6387849",
"0.6347757",
"0.62990326",
"0.6283147",
"0.62463605",
"0.6222771",
"0.62059665",
"0.61889166",
"0.617958",
"0.6176009",... | 0.82029665 | 0 |
This method is the inverse of Base::initialize. Instead of assigning instance variables from a hash, it iterates over an object's instance_variables to build a hash representation of them. Ruby prepends | def reload_obj(dirty_obj)
persisted_obj = dirty_obj.class.find_one(dirty_obj.id)
dirty_obj.instance_variable.each do |instance_variable|
dirty_obj.instance_variable_set(instance_variable, persisted_obj.instance_variable_get(instance_variable))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(hash={})\n # assign the attributes here (???)\n hash.each do |k, v| # name = id, name, etc.\n self.send(\"#{k}=\", v)\n # self.k = v # there's no '.k' method\n #binding.pry\n end\n end",
"def initialize(params={})\n\t\t\t\tparams.each_pair do |k,v|\n\t\t\t\t\tinstance_vari... | [
"0.7096979",
"0.7075312",
"0.69795835",
"0.6931437",
"0.68107194",
"0.67872137",
"0.6784826",
"0.67669857",
"0.6739661",
"0.6735136",
"0.67014766",
"0.669997",
"0.66953355",
"0.6694159",
"0.6694159",
"0.6694159",
"0.6694159",
"0.66543823",
"0.6610087",
"0.66006804",
"0.659950... | 0.0 | -1 |
by Hany for pundit end by hany for Devise layout start | def layout_by_resource
if devise_controller?
"devise_layout"
else
"application"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render layout: 'devise_layout' if current_user.present? && current_user.admin?\n end",
"def layout_by_resource\n if devise_controller? && action_name == \"new\"\n \"sinmenu\"\n end\n end",
"def layout_by_resource\n if user_signed_in?\n # \"admin\"\n #else\n \"application\"... | [
"0.6884638",
"0.65894437",
"0.6556364",
"0.64938176",
"0.64938176",
"0.64740324",
"0.6425371",
"0.64141256",
"0.63951206",
"0.6379952",
"0.62374645",
"0.62321883",
"0.6229712",
"0.62176514",
"0.6207268",
"0.6200789",
"0.61983806",
"0.61698556",
"0.61664987",
"0.6147479",
"0.6... | 0.57981974 | 54 |
GET /periods/1 GET /periods/1.xml | def show
@period = Period.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @period }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @period.to_xml }\n end\n end",
"def index\n @authorization_periods = AuthorizationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\... | [
"0.697887",
"0.65344566",
"0.6490071",
"0.64261526",
"0.6294119",
"0.6250508",
"0.6213859",
"0.60953885",
"0.60344595",
"0.6013452",
"0.59467125",
"0.59323853",
"0.590008",
"0.588166",
"0.58558226",
"0.57800007",
"0.5765523",
"0.57490605",
"0.5737154",
"0.57222354",
"0.568385... | 0.697724 | 2 |
GET /periods/new GET /periods/new.xml | def new
@period = @cursus.periods.build
respond_to do |format|
format.html { render :layout => false }
format.xml { render :xml => @period }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @period = Period.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @period }\n end\n end",
"def new\n @title = \"New Resources Periods\"\n @resource_period = ResourcePeriod.new\n\n respond_to do |format|\n format.html # new.html... | [
"0.74897796",
"0.6755607",
"0.67438114",
"0.6645171",
"0.6644948",
"0.6642514",
"0.65834355",
"0.64631915",
"0.64355683",
"0.6409539",
"0.6383805",
"0.61706525",
"0.61404735",
"0.6138096",
"0.6121987",
"0.6121013",
"0.612042",
"0.612042",
"0.6105411",
"0.606518",
"0.60650456"... | 0.690532 | 1 |
POST /periods POST /periods.xml | def create
@period = @cursus.periods.build(params[:period])
respond_to do |format|
if @period.save
format.html { redirect_to( cursus_periods_path(@cursus) ) }
format.xml { render :xml => @period, :status => :created, :location => @period }
else
format.js do
render :status => 500, :partial => "error_partial"
end
format.xml { render :xml => @period.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def periods_params\n params.require(:period).permit(:name, :comment, :start_date, :end_date, :budget_id)\n end",
"def create\n @period = Period.new(params[:period])\n\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, sta... | [
"0.64246845",
"0.6290774",
"0.62859964",
"0.6228496",
"0.62185895",
"0.61328846",
"0.6081976",
"0.6059283",
"0.6030935",
"0.60249627",
"0.6019644",
"0.5990538",
"0.59542876",
"0.5898787",
"0.57986146",
"0.57839024",
"0.5770097",
"0.5746094",
"0.5743232",
"0.5741344",
"0.57139... | 0.58366454 | 14 |
PUT /periods/1 PUT /periods/1.xml | def update
@period = @cursus.periods.find(params[:id])
respond_to do |format|
if @period.update_attributes(params[:period])
flash[:notice] = 'Period was successfully updated.'
format.html { redirect_to( cursus_periods_path(@cursus) ) }
format.xml { head :ok }
else
format.js do
render :status => 500, :partial => "error_partial"
end
format.xml { render :xml => @period.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @period = Period.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = 'Period was successfully updated.'\n format.html { redirect_to(@period) }\n format.xml { head :ok }\n else\n format.html { rende... | [
"0.6484507",
"0.6446026",
"0.63587046",
"0.624536",
"0.624536",
"0.624536",
"0.624536",
"0.61596715",
"0.5921498",
"0.58854413",
"0.5867411",
"0.58646244",
"0.5809602",
"0.5785171",
"0.5784812",
"0.57740974",
"0.572615",
"0.5706911",
"0.56858677",
"0.56444556",
"0.5569123",
... | 0.6023743 | 8 |
DELETE /periods/1 DELETE /periods/1.xml | def destroy
@period = Period.find(params[:id])
@period.destroy
respond_to do |format|
format.html { redirect_to( cursus_periods_path(@cursus) ) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to(periods_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n f... | [
"0.7264833",
"0.71584725",
"0.7007135",
"0.6955837",
"0.66590405",
"0.66505784",
"0.664139",
"0.64905083",
"0.63941115",
"0.63855994",
"0.63625205",
"0.63281256",
"0.62490964",
"0.62490135",
"0.6228565",
"0.62008375",
"0.617587",
"0.6149636",
"0.6128786",
"0.6108364",
"0.6105... | 0.67554444 | 4 |
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,10 15: 1,3,5,15 21: 1,3,7,21 28: 1,2,4,7,14,28 We can see that 28 is the first triangle number to have over five divisors. What is the value of the first triangle number to have over five hundred divisors? From StackOverflow: Hints: what is the formula for nth triangular number? n and n+1 have no common factors (except 1). Question: given number of factors in n and n+1 how to calculate number of factors in n(n+1)? What about n/2 and (n+1) (or n and (n+1)/2)? if you know all prime factors of n how to calculate number of divisors of n? | def sieve(x)
s = (0..x.to_i).to_a
s[0] = s[1] = nil
s.each{ |p| # Perform the block for each entry in the array.
next unless p # Iterate on next array value if entry is nil
break if p * p > x # Cease iteration if p*p > max_value
(p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to "nil" until max_value
}
s = s.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triangle_divisors(n)\n count = 2\n triangle = 1\n \n while\n triangle += count\n puts \"triangle is #{triangle}\"\n if number_of_factors(triangle) > n\n return triangle\n end\n count += 1\n end\nend",
"def triangle_divisor(divisor)\r\n\tstep = 1\r\n\ttriangle = 0\r\n\tcount = 0\r\n\r... | [
"0.78042316",
"0.7641671",
"0.7603189",
"0.73063123",
"0.7284914",
"0.72683084",
"0.71597695",
"0.7134039",
"0.70848864",
"0.7081967",
"0.7031492",
"0.702231",
"0.70128363",
"0.6969235",
"0.6949987",
"0.69363093",
"0.6912634",
"0.69066805",
"0.6903337",
"0.6895969",
"0.688760... | 0.0 | -1 |
Inicializa el plato con tres argumentos: El nombre del plato, la lista de alimentos y la lista del peso de estos alimentos | def initialize (nombre,&block)
@nombre = nombre
@lista = Listas.new()
@listagr = Listas.new()
if block_given?
if block.arity == 1
yield self
else
instance_eval(&block)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(nombre, platos)\n\t\t@nombre = nombre\n\t\t@platos = List.new\n\t\tfor plato in platos do\n\t\t\t@platos << plato\n\t\tend\n\tend",
"def initialize(nombre,alimentos,cantidad)\n @nombre_plato = nombre # Nombre del Plato\n @lista_alimentos = alimentos # Lista con los alimentos ... | [
"0.75948423",
"0.74806696",
"0.6430196",
"0.6042649",
"0.5900942",
"0.58953977",
"0.5888761",
"0.583618",
"0.5834506",
"0.5817067",
"0.58132565",
"0.57384425",
"0.5733541",
"0.570629",
"0.5689989",
"0.5669143",
"0.56585497",
"0.5587773",
"0.55867064",
"0.5567224",
"0.5549986"... | 0.0 | -1 |
Devuelve el porcentaje de proteinas de los alimentos en la lista | def prot
grtotal = 0
sum = 0
#itera en las dos listas a la vez para poder calcular las
#proteinas dependiendo de la cantidad y tambien suma
#todas las cantidades para poder calcular el porcentaje
#despues
@lista.zip(@listagr).each do |normal, gr|
grtotal += gr
cant = gr/1000.0
sum += normal.prot*cant
end
(sum*100)/grtotal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def porcentaje_proteinas\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.prot... | [
"0.75712186",
"0.745569",
"0.7149723",
"0.71058214",
"0.6997187",
"0.69279116",
"0.69185823",
"0.69174534",
"0.67578334",
"0.67186654",
"0.6548565",
"0.6401285",
"0.6373599",
"0.6345635",
"0.63302827",
"0.6183669",
"0.61441857",
"0.6132254",
"0.6110774",
"0.60939866",
"0.6084... | 0.6531954 | 11 |
Devuelve el porcentaje de lipidos de los alimentos en la lista | def lip
grtotal = 0
sum = 0
#itera en las dos listas a la vez para poder calcular las
#lipidos dependiendo de la cantidad y tambien suma
#todas las cantidades para poder calcular el porcentaje
#despues
@lista.zip(@listagr).each do |normal, gr|
grtotal += gr
cant = gr/1000.0
sum += normal.lip*cant
end
(sum*100)/grtotal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lipidos\n\t\treturn @lipidos*@cantidad\n\tend",
"def porcentaje_lipidos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n ... | [
"0.6922224",
"0.6846168",
"0.65876055",
"0.6431781",
"0.61838275",
"0.6118949",
"0.6088629",
"0.606659",
"0.60066",
"0.5936304",
"0.58227605",
"0.58082926",
"0.57529956",
"0.5724973",
"0.5722998",
"0.57205975",
"0.57114935",
"0.5624686",
"0.56010556",
"0.5575378",
"0.55415606... | 0.61981773 | 4 |
Devuelve el porcentaje de carbohidratos de los alimentos en la lista | def carbo
grtotal = 0
sum = 0
#itera en las dos listas a la vez para poder calcular las
#cabrohidratos dependiendo de la cantidad y tambien suma
#todas las cantidades para poder calcular el porcentaje
#despues
@lista.zip(@listagr).each do |normal, gr|
grtotal += gr
cant = gr/1000.0
sum += normal.carbo*cant
end
(sum*100)/grtotal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def porcentaje_lipidos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.lipido... | [
"0.70856917",
"0.7081741",
"0.67340094",
"0.6727324",
"0.6558635",
"0.64568347",
"0.6398554",
"0.636553",
"0.6354793",
"0.6332955",
"0.62779236",
"0.6260405",
"0.624348",
"0.62261814",
"0.62215585",
"0.6201042",
"0.61955035",
"0.6185234",
"0.61794966",
"0.6162606",
"0.6116202... | 0.6392535 | 7 |
Devuelve el valor energetico total, siendo este la suma de todos los valores energeticos de los alimentos | def vct
grtotal = 0
sum = 0
#recorre las dos listas a la vez para sacar el valor
#nutricional de cada ingrediente segun el peso de este
@lista.zip(@listagr).each do |normal, gr|
cant = gr/1000.0
sum += normal.val_en*cant
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculo_valor_calorico_total\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n acumulador = 0\n\n while (recorrido != nil && cantidad != nil)\n acumulador = acumulador + (((recorrido.value.proteinas * cantidad.value)/1000) * 4) + (((recorrido.value.lipidos * can... | [
"0.7801345",
"0.75953615",
"0.75719833",
"0.75447595",
"0.74794805",
"0.7475394",
"0.74084604",
"0.7201876",
"0.714915",
"0.71391714",
"0.7070051",
"0.70661396",
"0.70606476",
"0.70429116",
"0.70119995",
"0.69994986",
"0.69851625",
"0.69218004",
"0.6907074",
"0.68829495",
"0.... | 0.6485656 | 76 |
Devuelve el plato formateado | def to_s
string = @nombre + " ,Ingredientes: "
@lista.zip(@listagr).each do |normal, gr|
string += normal.nombre + " "
string += gr.to_s + " gr "
end
string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_plato_s\r\n aaa = \"\"\r\n aaa +=\"Plato: #{@nombre} \\n\"\r\n @lista_alimentos.each do |i|\r\n aaa +=\"Valor energético: #{i.val_ener} \\n\"\r\n end\r\n return aaa\r\n end",
"def platos(options = {})\n plato = options[:nombre]\n nombre_plato = plato.... | [
"0.64062184",
"0.6357404",
"0.6337269",
"0.6286646",
"0.58576596",
"0.58085454",
"0.5794861",
"0.5599799",
"0.55175865",
"0.5472756",
"0.5460662",
"0.54113203",
"0.53879315",
"0.5373294",
"0.536605",
"0.53602815",
"0.53516716",
"0.5335703",
"0.53335243",
"0.5331892",
"0.53206... | 0.0 | -1 |
Permite comparar platos por su valor energetico total | def <=> (other)
vct <=> other.vct
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valorsemaforo\n va = Float(valoractual)\n if va < Float(self.valorfinalrojo)\n 1\n elsif va < Float(self.valorfinalamarillo)\n 2\n else\n 3\n end\n end",
"def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n ... | [
"0.62825483",
"0.62064",
"0.6145978",
"0.61371344",
"0.60808647",
"0.6078517",
"0.6076519",
"0.60492235",
"0.6032232",
"0.60245836",
"0.6024375",
"0.60042644",
"0.5982968",
"0.59565896",
"0.59354764",
"0.5919332",
"0.5907339",
"0.5898129",
"0.58932996",
"0.5884366",
"0.588277... | 0.0 | -1 |
Inicializa subplato usando el initialize de la clase plato | def initialize(nombre,lista,listagr)
super(nombre,lista,listagr)
@gei = 0
@terreno = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(nombre, platos)\n\t\t@nombre = nombre\n\t\t@platos = List.new\n\t\tfor plato in platos do\n\t\t\t@platos << plato\n\t\tend\n\tend",
"def initialize(...)\n super\n mon_initialize\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def init; end",
"def init; end"... | [
"0.631851",
"0.62075806",
"0.6024455",
"0.6024455",
"0.6024455",
"0.6010467",
"0.6010467",
"0.6010467",
"0.6010467",
"0.5902726",
"0.5898603",
"0.58943474",
"0.58850664",
"0.5882713",
"0.5865234",
"0.5858763",
"0.5854551",
"0.5842785",
"0.5827869",
"0.58032185",
"0.57929856",... | 0.0 | -1 |
Devuelve las emisiones de gases totales del plato | def emisiones
grtotal = 0
sum = 0
#recorre las dos listas a la vez para sacar los gases emitidos
# de cada ingrediente segun el peso de este
@lista.zip(@listagr).each do |normal, gr|
cant = gr/1000.0
sum += normal.gases*cant
end
@gei = sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend",
"def huella\n\t\tindice1 = 0\n\t\t#dependiendo del vct de cada ingredien... | [
"0.7007304",
"0.64219606",
"0.63615984",
"0.61674726",
"0.6152264",
"0.6081921",
"0.6004554",
"0.5976921",
"0.59723467",
"0.5932031",
"0.5932031",
"0.5914249",
"0.59133124",
"0.5884698",
"0.58457065",
"0.58386594",
"0.5831559",
"0.57558656",
"0.57444376",
"0.5742091",
"0.5724... | 0.74137914 | 0 |
Devuelve la cantidad de terreno usado total del plato | def terreno
grtotal = 0
sum = 0
#recorre las dos listas a la vez para sacar el terreno
#usado de cada ingrediente segun el peso de este
@lista.zip(@listagr).each do |normal, gr|
cant = gr/1000.0
sum += normal.terreno*cant
end
@terreno = sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\t@platos.each do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend",
"def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(... | [
"0.7538809",
"0.72674954",
"0.7005634",
"0.6921853",
"0.6915203",
"0.68969107",
"0.6772101",
"0.6701636",
"0.66948617",
"0.6673541",
"0.6666854",
"0.6627229",
"0.65935284",
"0.6584838",
"0.65822995",
"0.65815425",
"0.64792293",
"0.64722085",
"0.6446697",
"0.64099574",
"0.6390... | 0.6598443 | 12 |
Devuelve el subplato formateado | def to_s
string = "Gases " + @gei.to_s + " Uso de terreno anual " + @terreno.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_socioeduk_subforma_entrada\n @socioeduk_subforma_entrada = Socioeduk::SubformaEntrada.find(params[:id])\n end",
"def formation; end",
"def partido\n localidad.partido\n end",
"def to_s() # :nodoc:\n mano_seleccionada = super.to_s\n if not @movimientos.nil?\n return \"... | [
"0.59966326",
"0.5819607",
"0.57580656",
"0.5590646",
"0.5560854",
"0.55449665",
"0.5520069",
"0.55178744",
"0.5517249",
"0.5474457",
"0.5380645",
"0.5361924",
"0.5354927",
"0.53380233",
"0.5329441",
"0.5319763",
"0.53035355",
"0.52955365",
"0.527948",
"0.52722704",
"0.526906... | 0.0 | -1 |
Permite calcular la huella energetica de cada subplato | def huella
indice1 = 0
#dependiendo del vct de cada ingrediente, se le pone un indice
if vct < 670
indice1 = 1
elsif vct > 830
indice1 = 3
else
indice1 = 2
end
indice2 = 0
#dependiendo de los gases emitidos de cada ingrediente,
#se le pone un indice
if emisiones < 800
indice2 = 1
elsif emisiones > 1200
indice2 = 3
else
indice2 = 2
end
#hace la media de los indices sacados
indiceres = (indice1+indice2)/2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend",
"def get_energia\n\t\t\t\t@lipidos * 9 + @proteins * 4 + @carbs * 4\n\t\t\tend",
"def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n ... | [
"0.6618011",
"0.66050166",
"0.6540343",
"0.6513198",
"0.64192027",
"0.64056027",
"0.64035386",
"0.63332355",
"0.6322997",
"0.6319128",
"0.6309427",
"0.6189992",
"0.6164476",
"0.6161472",
"0.6161069",
"0.6158572",
"0.6151993",
"0.6151541",
"0.6120761",
"0.6105959",
"0.6104845"... | 0.6157524 | 16 |
If the numbers is even return true. If it's odd, return false. Oh yeah... the following symbols/commands have been disabled! use of % use of .even? in Ruby use of mod in Python | def is_even(n)
return n % 2 === 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd?(num)\n # num.abs % 2 != 0 \n num % 2 == 1\n # ruby modulus operator always return non-negative result if num on right is positive\n # ie, % is a modulus operator and \"not a remainder operator as in some languages\"\n # my first line was correct, but more properly per the proposed problem\n # ch... | [
"0.8336703",
"0.82884896",
"0.8286844",
"0.82431364",
"0.82319057",
"0.82111967",
"0.8197993",
"0.8197993",
"0.8197993",
"0.8171983",
"0.8166805",
"0.81619227",
"0.81619227",
"0.8155062",
"0.81457776",
"0.81422406",
"0.8137257",
"0.8131523",
"0.8128214",
"0.8124032",
"0.81218... | 0.80281126 | 36 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.