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
Validates if not an admin user then redirects to the home page. (root path)
def authorize_admin redirect_to root_path, flash: {:error => "User don't have admin privileges"} unless isAdmin? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin_user\n redirect_to(root_path) unless is_admin?\n end", "def check_for_admin\n\t\tif current_user.nil? || !current_user.is_admin?\n\t\t\tredirect_to root_path, alert:\"You must be an admin to access this path\"\n\t\tend\n\tend", "def admin_user\n if logged_in?\n redirect_to(root_url)...
[ "0.8628732", "0.8520014", "0.8497765", "0.8483384", "0.8476432", "0.8476432", "0.8476432", "0.8476432", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "0.8451317", "...
0.0
-1
Check out a book, takes a Borrower object
def check_out(borrower_obj) overdue = check_overdue(borrower_obj) cur_date = Time.new #Only check out a book if it is available, #the borrower doesn't have 2 already checked out #and does not have any over due books, and #there is no one on the waitlist or the person trying #to check out the book is the next person on the waitlist if (@status == 'available' && borrower_obj.checked_out.length < 2 && !overdue && (@waitlist.length == 0 || @waitlist.first.name == borrower_obj.name)) @status = 'checked_out' #Adds the borrower to the book borrower array #Might be able to go with = and remove all of the .firsts @borrower << borrower_obj #Sets the due date as time checked out + 7 days @due_date = Time.now + 604800 #Removes the person from the waitlist if they're on it @waitlist.shift if @waitlist.length > 0 #Tells the calling method the book was checked out return true else #Adds the borrower to the waitlist @waitlist << borrower_obj #Tells the calling method the book was not checked out return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_out(borrower, book)\n if borrower.borrowed_books.size == 2\n puts \"Sorry, \" + borrower.name + \", you cannot check out any more books until you return one.\"\n elsif (book.status == \"Checked out\") \n puts \"Sorry, \" + borrower.name + \", that book is not available.\"\n ...
[ "0.75203115", "0.72900975", "0.7274828", "0.7202062", "0.7186333", "0.71168226", "0.7105372", "0.7060018", "0.7056492", "0.7051449", "0.70289457", "0.69719154", "0.69688034", "0.6968757", "0.69187665", "0.69169766", "0.6894241", "0.6880243", "0.685886", "0.67866397", "0.67827...
0.6280408
47
Checks in the book, making it available and setting borrower array to empty. Returns the borrower array before emptying it to clear the book from borrower object. Not very elegant. Is there a this for the book object? so I could call a borrower.checked_out.delete(this)?
def check_in @status = 'available' return @borrower @borrower = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_in_book(book)\n borrower = book.check_in\n #Removes the book from the borrower's checked out array\n borrower.first.checked_out.delete(book)\n end", "def check_out(user, book)\n# .borrowerd_books refers to the \"getter/setter\" methods defined in the Borrower class which enables\n# us to retr...
[ "0.7678215", "0.72644764", "0.6909984", "0.6768453", "0.67594373", "0.6697459", "0.66801816", "0.6624507", "0.6593237", "0.6577832", "0.6577832", "0.65576404", "0.6512176", "0.64111036", "0.63147604", "0.62862515", "0.6247679", "0.6207061", "0.6154855", "0.6138877", "0.613259...
0.620559
18
Checks out a book by the book id
def check_out_book(book_id, borrower) #Runs through each book in the library @books.each do |book| #If the book's id matches the id of the checkout id, #tries to check the book out if book.id == book_id && book.check_out(borrower) borrower.checked_out << book return book end end #If no match is found, returns nil return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_out_book\n\tselect = make_selection.to_i\n\tselect = verify_book_exists(select)\n\tb = Book.find(select)\n\tif b.patron_id.nil?\n\t\tputs \"\\nPlease select patron that would like to check out book\\n\"\n\t\tshow_all_patrons\n\t\tselect = make_selection.to_i\n\t\tselect = verify_patron_exists(select)\n\t...
[ "0.7501843", "0.74373066", "0.7268408", "0.72001636", "0.7162231", "0.70276284", "0.69301826", "0.6782223", "0.67516714", "0.6750026", "0.6694539", "0.66896087", "0.6652022", "0.66315305", "0.6630679", "0.66018623", "0.65837365", "0.6574006", "0.65664345", "0.6562539", "0.655...
0.76180017
0
Figures out who is borrowing a book by a specific book id
def get_borrower(book_id) #Runs through all books in the library and finds the one #that matches the id, then looks at the borrower #Currently no error protection if the book isn't borrowed @books.each do |book| return book.borrower.first.name if book.id == book_id end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def borrow(book_id, user_id)\r\n @@books.each do |book|\r\n @@users.each do |user|\r\n if book.bookID == book_id && user.userID == user_id\r\n if book.status == \"available\"\r\n book.borrower = (user.fname+\" \"+user.lname)\r\n book.status = \"borrowed\"\r\n ...
[ "0.76648736", "0.6958393", "0.67940766", "0.67940766", "0.67940766", "0.6533996", "0.65253675", "0.6513478", "0.64999646", "0.6473955", "0.6472025", "0.64569634", "0.644544", "0.6440143", "0.6380954", "0.63694733", "0.6364664", "0.63446534", "0.63396645", "0.6320646", "0.6316...
0.7807123
0
Checks in a book This one is not by ID, it's by the book object itself
def check_in_book(book) borrower = book.check_in #Removes the book from the borrower's checked out array borrower.first.checked_out.delete(book) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_in(book)\n @book = book\n end", "def check_in(book)\n end", "def check_in(book)\n book.status = \"available\"\n book.borrower.borrowed_books.delete(book.borrower.borrowed_books[book])\n end", "def verify_book_exists(selected)\n\twhile Book.find_by_id(selected).nil?\n\t\tputs \"\\nNo boo...
[ "0.7530567", "0.7363779", "0.70819527", "0.688228", "0.67921585", "0.67384624", "0.6686628", "0.662655", "0.65911186", "0.65601355", "0.6533116", "0.65008205", "0.6499413", "0.6486458", "0.64239824", "0.6396185", "0.63506323", "0.62986594", "0.6294813", "0.62787", "0.6270922"...
0.64142525
15
Returns an array of book objects of available books
def available_books @books.select { |book| book.status == 'available' } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def available\n @books = Book.all\n end", "def available_books\n @books.each do |book|\n if book.status == \"available\"\n puts \"#{book.title} by #{book.author} is available.\"\n end\n end\n end", "def all_books\n\t\t\t@books = Book.all\n\t\tend", "def get_books()\n @books_out...
[ "0.7939928", "0.753017", "0.73446137", "0.7309682", "0.7309682", "0.7294086", "0.72789454", "0.7247439", "0.71612203", "0.7139511", "0.7136423", "0.71248186", "0.71187294", "0.71158767", "0.7111274", "0.7015461", "0.69793993", "0.6878958", "0.6862787", "0.6784979", "0.6783060...
0.7852823
1
Returns an array of book objects of unavailable books
def borrowed_books @books.select { |book| book.status == 'checked_out' } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def available_books\n @books.select { |book| book.status == 'available' }\n end", "def available_books\n @books.each do |book|\n if book.status != \"Checked out\"\n puts book.title + \" is available to check out.\"\n end\n end\n end", "def available_books\n @books.each do |book|\...
[ "0.7391828", "0.7308739", "0.7177836", "0.6970157", "0.68303907", "0.6814053", "0.67785215", "0.66758275", "0.6649029", "0.65947217", "0.65822107", "0.6445125", "0.63031214", "0.6262875", "0.6142814", "0.6135169", "0.60778815", "0.60686255", "0.6054412", "0.6045405", "0.60177...
0.6972636
3
Prints a list of checked out books titles, due dates and who borrowed it
def book_due_dates borrowed_books.each { |book| puts "#{book.title} checked out by #{book.borrower.first.name}. Due date: #{book.due_date.strftime("%B %d, %Y")}."} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def borrowed_books_list\n puts \"#{@name} has checked out:\"\n @books.each do |book|\n puts \" \\\"#{book.title}\\\"\"\n end\n end", "def borrowed_books\n puts \"The following books have been checked out:\"\n @books.each do |book|\n if book.checked_out\n puts \" \\\"#{book....
[ "0.8512175", "0.83074945", "0.82268405", "0.8058411", "0.80368286", "0.7949579", "0.7830544", "0.7786242", "0.77680004", "0.7726294", "0.75562936", "0.7430659", "0.72287184", "0.7223901", "0.7213249", "0.7074289", "0.70168334", "0.68900466", "0.68446434", "0.684278", "0.66496...
0.8132467
3
Prints out a list of overdue books with the title and the due date
def overdue_books borrowed_books.each do |book| puts "#{book.title} was due on #{book.due_date.strftime("%B %d, %Y")}.}" if book.check_overdue(book.borrower.first) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_overdue\n @checked_out.each do |book|\n book.is_overdue\n end\n \n puts \"The following books are overdue:\"\n @overdue.each { |book| puts \"#{book.title} - #{book.author}\" }\n end", "def book_due_dates\n borrowed_books.each { |book| puts \"#{book.title} checked out by #{book.bo...
[ "0.7954493", "0.7645872", "0.75196224", "0.7025592", "0.6729006", "0.6619297", "0.65818906", "0.6560204", "0.6448806", "0.64484096", "0.6429245", "0.64276785", "0.6359459", "0.6349493", "0.6257278", "0.62519556", "0.6200015", "0.6147257", "0.61210984", "0.60482675", "0.599742...
0.8292053
0
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) min_name = nil min_number = nil name_hash.each do |name, number| if min_number == nil || number < min_number min_number = number min_name = name end end return min_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n...
[ "0.8821222", "0.8777674", "0.87769854", "0.8745862", "0.8689437", "0.86553806", "0.865241", "0.86165065", "0.8587693", "0.8572328", "0.85674095", "0.8550907", "0.8529734", "0.8529734", "0.85182345", "0.84936565", "0.8475531", "0.8475531", "0.8466132", "0.8449126", "0.84490585...
0.0
-1
GET /enrolls GET /enrolls.json
def index @enrolls = Enroll.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @enrolls = Enroll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @enrolls }\n end\n end", "def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end", "def show\n @enroll = Enroll.find(par...
[ "0.7716358", "0.7465079", "0.72161114", "0.7063669", "0.7063669", "0.7063669", "0.7063669", "0.7004954", "0.68922853", "0.68714327", "0.68692726", "0.68692726", "0.68355024", "0.6773457", "0.67266697", "0.66915876", "0.6670917", "0.6646552", "0.66369957", "0.65649503", "0.652...
0.7515036
1
GET /enrolls/2 GET /enrolls/2.json
def show @enroll = Enroll.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @enroll = Enroll.find(params[:id])\n render json: JSON.parse(@enroll.to_json)\n end", "def show\n @enroll = Enroll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @enroll }\n end\n end", "def index\n @enrolls = Enr...
[ "0.7240592", "0.71023625", "0.68652326", "0.66395324", "0.64903235", "0.6399955", "0.6328003", "0.6309878", "0.6295461", "0.6284851", "0.62361264", "0.6224104", "0.61996967", "0.61996967", "0.61996967", "0.61996967", "0.61880374", "0.61880374", "0.61880374", "0.61880374", "0....
0.67501503
3
POST /enrolls POST /enrolls.json
def create @enroll = Enroll.new(enroll_params) respond_to do |format| if @enroll.save format.html { redirect_to @enroll, notice: 'Enroll was successfully created.' } format.json { render :show, status: :created, location: @enroll } else format.html { render :new } format.json { render json: @enroll.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end", "def create\n @enroll = Enroll.new(params[:enroll])\n @enroll.view =0\n if @enroll.save\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n e...
[ "0.7566003", "0.7204799", "0.7179745", "0.6776496", "0.66707337", "0.6614518", "0.6611406", "0.65864503", "0.65864503", "0.65718466", "0.6529844", "0.6508913", "0.647163", "0.6457144", "0.64416146", "0.641476", "0.63484436", "0.6346371", "0.6336148", "0.6336148", "0.6336148",...
0.7462776
1
PATCH/PUT /enrolls/1 PATCH/PUT /enrolls/1.json
def update respond_to do |format| if @enroll.update(enroll_params) format.html { redirect_to @enroll, notice: 'Enroll was successfully updated.' } format.json { render :show, status: :ok, location: @enroll } else format.html { render :edit } format.json { render json: @enroll.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end", "def update\n respond_to do |format|\n if @enroll.update(enroll_params)\...
[ "0.74623483", "0.7106469", "0.69208634", "0.67900336", "0.6747975", "0.65869105", "0.6576283", "0.6560799", "0.6560799", "0.6560799", "0.6560799", "0.6560799", "0.6528338", "0.6427739", "0.64209473", "0.6353271", "0.6339591", "0.62995934", "0.6297268", "0.6296809", "0.6284526...
0.72297525
2
DELETE /enrolls/1 DELETE /enrolls/1.json
def destroy @enroll.destroy respond_to do |format| format.html { redirect_to enrolls_url, notice: 'Enroll was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({m...
[ "0.7937095", "0.78918463", "0.769313", "0.76297796", "0.7512439", "0.73133063", "0.73133063", "0.73133063", "0.73133063", "0.73133063", "0.72751975", "0.72677577", "0.7267682", "0.7247389", "0.7242299", "0.7142559", "0.7133361", "0.7058846", "0.70414436", "0.6952568", "0.6947...
0.7638765
3
Use callbacks to share common setup or constraints between actions.
def set_enroll @enroll = Enroll.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def enroll_params params.require(:enroll).permit(:student_id, :course_id, :percentage, :lettergrade) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69811666", "0.6782836", "0.6747644", "0.6742015", "0.6735273", "0.6593917", "0.65037674", "0.6498627", "0.6482372", "0.64795715", "0.64566946", "0.6439213", "0.6380714", "0.6378147", "0.63657266", "0.63206697", "0.6300169", "0.62992156", "0.6295538", "0.62943023", "0.62915...
0.0
-1
Returns the amount of points for an IOIstyle task submission.
def points raise "Not an IOI style task." unless task.scoring == "ioi" total = body.count.to_f raise "Task has no tests." unless total > 0 passed = body.count { |test| test[:status] == "Correct" } ((passed / total) * 100).round end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points\n\t\tpoints = 0\n\t\tassignments.each do |assignment|\n\t\t\tpoints += assignment.worth\n\t\tend\n\t\treturn points\n\tend", "def tasks_progress\n total_done = 0\n total_tasks = 0\n self.stories.each do |story|\n story.issues.each do |issue|\n total_tasks += 1\n ...
[ "0.6237455", "0.61889195", "0.61604905", "0.60764974", "0.60261226", "0.6003601", "0.59693485", "0.59660524", "0.59188884", "0.5908491", "0.5869018", "0.5865915", "0.5865915", "0.5837671", "0.5826336", "0.58262485", "0.5817888", "0.5803442", "0.5781929", "0.57782316", "0.5741...
0.73562694
0
GET /payment_sources/1 GET /payment_sources/1.json
def show @payment_source = PaymentSource.find(params[:id]) @transactions = @payment_source.transactions respond_to do |format| format.html # show.html.erb format.json { render json: @payment_source } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_sources(source)\n get('account/sources', {'source' => source})\n end", "def sources(source: nil)\n params = {\n source: source\n }.compact\n\n _get(\"/account/sources\", params) { |json| json }\n end", "def sources_get(opts = {})\n if Configuration.de...
[ "0.72408015", "0.71413076", "0.7001796", "0.68813616", "0.6713095", "0.6601706", "0.6363182", "0.6324483", "0.62809914", "0.623632", "0.61457956", "0.61139697", "0.6061594", "0.60169715", "0.601139", "0.59875745", "0.5945886", "0.5929346", "0.59282047", "0.5922494", "0.591039...
0.7026315
2
GET /payment_sources/new GET /payment_sources/new.json
def new @payment_source = PaymentSource.new @payment_source_types = PaymentSourceType.all respond_to do |format| format.html # new.html.erb format.json { render json: @payment_source } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @payment_source_type = PaymentSourceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @payment_source_type }\n end\n end", "def create\n @payment_source = PaymentSource.new(params[:payment_source])\n\n respond_to do |format|\n i...
[ "0.73689735", "0.7250581", "0.713299", "0.69118047", "0.6819996", "0.669418", "0.66120625", "0.65608287", "0.6526889", "0.6514411", "0.64072496", "0.64040595", "0.6402731", "0.6360776", "0.6360631", "0.63507324", "0.63507324", "0.63457906", "0.63141394", "0.63141394", "0.6314...
0.77349895
0
POST /payment_sources POST /payment_sources.json
def create @payment_source = PaymentSource.new(params[:payment_source]) respond_to do |format| if @payment_source.save format.html { redirect_to @payment_source, notice: 'Payment source was successfully created.' } format.json { render json: @payment_source, status: :created, location: @payment_source } else format.html { render action: "new" } format.json { render json: @payment_source.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sources_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: SourceApi#sources_post ...\"\n end\n \n # resource path\n path = \"/sources\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access...
[ "0.6804341", "0.6597224", "0.64304405", "0.6221949", "0.6177278", "0.6126596", "0.6119204", "0.59598273", "0.586675", "0.58340836", "0.58004415", "0.5746512", "0.5736439", "0.57295907", "0.5723741", "0.5701985", "0.5691895", "0.5654129", "0.55806804", "0.55771476", "0.5573979...
0.70148623
0
PUT /payment_sources/1 PUT /payment_sources/1.json
def update @payment_source = PaymentSource.find(params[:id]) respond_to do |format| if @payment_source.update_attributes(params[:payment_source]) format.html { redirect_to @payment_source, notice: 'Payment source was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @payment_source.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n source = Source.find_by(id: params[:source_id])\n unless source_params[:name] == source.name\n render json: {error: 'You cannot change external api for a source, you must delete that source if you wish to remove it'}, status: :unprocessable_entity\n end\n if source && all_sources.incl...
[ "0.70927197", "0.6461463", "0.62925756", "0.62775517", "0.6196611", "0.61962694", "0.6175205", "0.6069361", "0.6018507", "0.5975896", "0.5927411", "0.59071404", "0.58900386", "0.5882455", "0.586343", "0.5849872", "0.57957315", "0.57957315", "0.57957315", "0.5730321", "0.57254...
0.692222
1
DELETE /payment_sources/1 DELETE /payment_sources/1.json
def destroy @payment_source = PaymentSource.find(params[:id]) @payment_source.destroy respond_to do |format| format.html { redirect_to payment_sources_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @payment_source_type = PaymentSourceType.find(params[:id])\n @payment_source_type.destroy\n\n respond_to do |format|\n format.html { redirect_to payment_source_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @source = Source.find(params[:id])\n ...
[ "0.72450477", "0.7028552", "0.7028552", "0.70282453", "0.69855404", "0.69223285", "0.6842904", "0.68233", "0.6772394", "0.6772394", "0.6772394", "0.6772394", "0.6751411", "0.67398846", "0.6728839", "0.6714342", "0.67058474", "0.6662588", "0.66268635", "0.6617845", "0.6617739"...
0.79653907
0
GET /small_generators/1 GET /small_generators/1.json
def show @small_generator = SmallGenerator.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @small_generator } format.pdf do pdf = SmallGeneratorsPdf.new @small_generator, view_context send_data pdf.render, type: "application/pdf", disposition: "inline", filename: "#{@small_generator.model}.pdf" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @small_generator = SmallGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @small_generator }\n end\n end", "def index\n @generator = Generator.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json...
[ "0.7326263", "0.71268773", "0.7094266", "0.6728521", "0.6664552", "0.66226184", "0.65938395", "0.65120286", "0.64537835", "0.6293158", "0.62556785", "0.624131", "0.61859566", "0.6095163", "0.60420907", "0.60244507", "0.59624094", "0.59004647", "0.5897385", "0.5885874", "0.580...
0.5919017
17
GET /small_generators/new GET /small_generators/new.json
def new @small_generator = SmallGenerator.new respond_to do |format| format.html # new.html.erb format.json { render json: @small_generator } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @generator = Generator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator }\n end\n end", "def create\n @small_generator = SmallGenerator.new(params[:small_generator])\n\n respond_to do |format|\n if @small_generator.save\n...
[ "0.79595774", "0.7615194", "0.7517366", "0.72744465", "0.72253937", "0.70087767", "0.6942284", "0.693753", "0.6910441", "0.68173707", "0.67415756", "0.65400094", "0.65294325", "0.65252334", "0.650611", "0.6468533", "0.6453294", "0.6451115", "0.64474094", "0.64065945", "0.6379...
0.8365124
0
POST /small_generators POST /small_generators.json
def create @small_generator = SmallGenerator.new(params[:small_generator]) respond_to do |format| if @small_generator.save format.html { redirect_to @small_generator, notice: 'Small generator was successfully created.' } format.json { render json: @small_generator, status: :created, location: @small_generator } else format.html { render action: "new" } format.json { render json: @small_generator.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @small_generator = SmallGenerator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @small_generator }\n end\n end", "def create\n @generator = Generator.new(generator_params)\n\n respond_to do |format|\n if @generator.save\n ...
[ "0.6937142", "0.6528091", "0.64879817", "0.612914", "0.6087337", "0.6036949", "0.59903395", "0.5936504", "0.59143615", "0.59031165", "0.5901401", "0.58515215", "0.5836164", "0.5818855", "0.5804857", "0.5743563", "0.5729532", "0.5647138", "0.5628818", "0.5622246", "0.56015986"...
0.7366782
0
PUT /small_generators/1 PUT /small_generators/1.json
def update @small_generator = SmallGenerator.find(params[:id]) respond_to do |format| if @small_generator.update_attributes(params[:small_generator]) format.html { redirect_to @small_generator, notice: 'Small generator was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @small_generator.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @small_generator = SmallGenerator.new(params[:small_generator])\n\n respond_to do |format|\n if @small_generator.save\n format.html { redirect_to @small_generator, notice: 'Small generator was successfully created.' }\n format.json { render json: @small_generator, status: :cre...
[ "0.6673098", "0.62664557", "0.6249139", "0.6249139", "0.610853", "0.60386705", "0.5964713", "0.5902038", "0.57944196", "0.5668173", "0.56261605", "0.56163704", "0.56082374", "0.5593229", "0.55172664", "0.5478563", "0.5478563", "0.5456768", "0.54156834", "0.5412201", "0.540673...
0.70032233
0
DELETE /small_generators/1 DELETE /small_generators/1.json
def destroy @small_generator = SmallGenerator.find(params[:id]) @small_generator.destroy respond_to do |format| format.html { redirect_to small_generators_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirect_to generators_url...
[ "0.74329805", "0.7080362", "0.7080362", "0.6815952", "0.6708541", "0.67075557", "0.6676225", "0.6595754", "0.65533453", "0.647257", "0.63749063", "0.636435", "0.63554895", "0.6352927", "0.6332488", "0.6309197", "0.6304103", "0.62965065", "0.62794715", "0.6274813", "0.6254501"...
0.77374035
0
GET /users/1 or /users/1.json
def show; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.78865844", "0.7556877", "0.75155014", "0.7297117", "0.72272533", "0.7221837", "0.7198221", "0.7147842", "0.71043974", "0.7094858", "0.70760095", "0.69551945", "0.69483835", "0.6932976", "0.6927552", "0.69053364", "0.6885359", "0.6830757", "0.6830757", "0.68155175", "0.6811...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @attendee = Attendee.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
defining a method that reads the contents of a file and prints it out
def print_all(f) puts f.read() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_all(f)\n # read the file\n puts f.read\nend", "def print_file_content file_name\n\n \tputs \"\\n===========================================\"\n \tputs \"Printing the content of the file\"\n \tputs \"===========================================\\n\"\n\n\t# Open file\n\tfile = File.open(file_name)\...
[ "0.78495514", "0.77089995", "0.76987606", "0.76987505", "0.76551354", "0.7632475", "0.7612324", "0.75067806", "0.749668", "0.7483832", "0.74581647", "0.7362206", "0.7353573", "0.73436654", "0.73103094", "0.7299389", "0.72375226", "0.7209823", "0.71977717", "0.7090937", "0.706...
0.685164
79
defining a method that sets the file's pointer to the begining of the file, the first byte.
def rewind(f) f.seek(0, IO::SEEK_SET) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rewind(f)\n # the seek method tries to find a position (given as an integer)\n # if we send a file to our \"rewind\" method, it will \"seek\" position 0\n # position 0 is the beginning of the File\n f.seek(0)\nend", "def rewind(f)\n # '.seek()' command moves to the start of the file\n f.seek(0)\nen...
[ "0.72533846", "0.7161141", "0.7155733", "0.70175743", "0.6989409", "0.69873977", "0.69731236", "0.69731236", "0.69731236", "0.69731236", "0.69731236", "0.69731236", "0.69731236", "0.6971759", "0.6958811", "0.6958811", "0.69535846", "0.69404644", "0.69293356", "0.691842", "0.6...
0.67904073
63
defining a method that prints out specific lines of the file
def print_a_line(line_count, f) puts "#{line_count } #{f.readline()}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_it_lines\n open(file_name).each {|x| p x; }\n end", "def print_file(*) end", "def print_all(f)\n puts f.read #reads note to self you have to manually reset the line that its at\nend", "def print_all(f) # defining a new method/function (print_all) that takes the paramter f as an argument\n puts f...
[ "0.7127995", "0.70469296", "0.6948912", "0.67452955", "0.67265546", "0.6701753", "0.6694643", "0.6689338", "0.6689338", "0.663042", "0.6599894", "0.6566276", "0.65436786", "0.6535124", "0.6529503", "0.6524665", "0.65243816", "0.6522647", "0.65011394", "0.6454185", "0.64335585...
0.0
-1
GET /expenses GET /expenses.json
def index @expenses = get_class.all respond_to do |format| format.html # index.html.erb format.json { render json: @expenses } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def expenses\n @expenses ||= Harvest::API::Expenses.n...
[ "0.8207424", "0.7868928", "0.7521715", "0.7485303", "0.7466285", "0.73566276", "0.71818566", "0.7099663", "0.70841765", "0.70841765", "0.70841765", "0.70841765", "0.70841765", "0.7070414", "0.6989723", "0.69714546", "0.6969409", "0.6900681", "0.6863176", "0.6781842", "0.67756...
0.72700804
6
GET /expenses/1 GET /expenses/1.json
def show respond_to do |format| format.html # show.html.erb format.json { render json: @expense } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end", "def index\n @api_v1_expenses = Api::V1::Expense.all\n ...
[ "0.7852153", "0.76643664", "0.7582055", "0.73080707", "0.73080707", "0.73080707", "0.73080707", "0.73080707", "0.7251809", "0.72369164", "0.72013515", "0.71863693", "0.70798296", "0.6971261", "0.6900109", "0.6899645", "0.6838902", "0.68240345", "0.67582136", "0.67378426", "0....
0.69470507
14
GET /expenses/new GET /expenses/new.json
def new @expense = get_class.new @expense.total_price = 0 @expense.team_fee = 0 @expense.player_fee = 0 respond_to do |format| format.html # new.html.erb format.json { render json: @expense } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @expense = Expense.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expense }\n end\n end", "def new\n @expense = Expense.new\n @assigned_categories = \"\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.js...
[ "0.7913088", "0.7499853", "0.73921776", "0.7384509", "0.73416615", "0.7272794", "0.7249887", "0.7249887", "0.7135003", "0.71259457", "0.7052109", "0.7048145", "0.70458424", "0.7038827", "0.7021232", "0.6957", "0.6905619", "0.68755287", "0.6871418", "0.68626", "0.68626", "0....
0.71405125
8
POST /expenses POST /expenses.json
def create @expense = get_class.new(params[get_type]) @expense.creator_id = current_user.id respond_to do |format| if @expense.save and @expense.create_expense_posting(price: @expense.calc_expense_posting_price) format.html { redirect_to @expense, notice: 'Udalosť bola úspešne vytvorená.' } format.json { render json: @expense, status: :created, location: @expense } else format.html { render action: "new" } format.json { render json: @expense.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @expense = Expense.new(expense_params)\n\n if @expense.save\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end", "def create\n # Get the variables passed in from params on create\n @expense = Expense.new(expense_param...
[ "0.7261324", "0.7084191", "0.70350605", "0.6900912", "0.6843917", "0.6822504", "0.67079735", "0.65698487", "0.65261096", "0.6502184", "0.6492159", "0.6477112", "0.6404915", "0.640302", "0.6383205", "0.63663673", "0.63563615", "0.6343615", "0.63217306", "0.63024414", "0.629572...
0.5856838
73
PUT /expenses/1 PUT /expenses/1.json
def update respond_to do |format| if @expense.update_attributes(params[get_type]) update_paps format.html { redirect_to @expense, notice: 'Udalosť bola úspešne zmenená.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @expense.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end", "def update\n @expense = Expense.find params.fetch(:id)\n\n if @expense.update(expense_params)\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n ...
[ "0.7602887", "0.7279367", "0.7135041", "0.7131239", "0.7019494", "0.7018134", "0.6808176", "0.67709774", "0.6737069", "0.6737069", "0.671457", "0.67037684", "0.67037684", "0.66839755", "0.66839755", "0.66839755", "0.66695786", "0.66647965", "0.66481364", "0.6638962", "0.66260...
0.0
-1
DELETE /expenses/1 DELETE /expenses/1.json
def destroy @expense.destroy respond_to do |format| format.html { redirect_to expenses_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n ...
[ "0.7657695", "0.7657695", "0.7635413", "0.762301", "0.7556879", "0.7556879", "0.74879384", "0.74002934", "0.7357415", "0.7357415", "0.7334415", "0.72726315", "0.72726315", "0.72726315", "0.72726315", "0.72726315", "0.72726315", "0.7239536", "0.72328955", "0.7210207", "0.71496...
0.75940335
4
Find the largest palindrome made from the product of two 3digit numbers.
def is_palindrome(input) input_as_string = input.to_s return input_as_string == input_as_string.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def largest_palindrome_product\n palindromes = []\n\n 999.downto(100) do |x|\n 999.downto(100).each do |y|\n if (x * y).to_s == (x * y).to_s.reverse\n palindromes << x * y\n end\n end\n end\n palindromes.max\nend", "def problem_4\n num1 = 999\n largest_pal = 0\n\n while num1 > 99\n ...
[ "0.82818377", "0.827763", "0.8186478", "0.8184319", "0.8155215", "0.8108478", "0.80946875", "0.8067113", "0.806694", "0.80053306", "0.7943394", "0.7915469", "0.7899477", "0.78876203", "0.7870736", "0.77883846", "0.77644616", "0.77371234", "0.77238166", "0.76934046", "0.764019...
0.0
-1
Synchronize this entry with the given entry's values.
def sync(source_entry) [ :entry_status, :entry_author_id, :entry_allow_comments, :entry_allow_pings, :entry_convert_breaks, :entry_title, :entry_excerpt, :entry_text, :entry_text_more, :entry_to_ping_urls, :entry_pinged_urls, :entry_keywords, :entry_tangent_cache, :entry_created_on, :entry_modified_on, :entry_created_by, :entry_modified_by, :entry_basename, :entry_week_number ].each do |attribute| self[attribute] = source_entry[attribute] end # Sync placements ONLY if this entry has been previously saved. unless self.new_record? # Add or update placements. source_entry.placements.each do |source_placement| # Category may not exist yet; copy if so. target_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => self.entry_blog_id, :category_label => source_placement.category.category_label }) target_category = MovableType::AR::Category.create(self.blog, source_placement.category) if target_category.blank? target_placement = self.placements.find(:first, :conditions => { :placement_category_id => target_category.category_id }) target_placement.blank? ? self.placements << MovableType::AR::Placement.create(self, source_placement) : target_placement.sync!(source_placement) end # Remove old placements. if self.placements.size > source_entry.placements.size self.placements.each do |target_placement| source_category = MovableType::AR::Category.find(:first, :conditions => { :category_blog_id => source_entry.entry_blog_id, :category_label => target_placement.category.category_label }) if source_category.blank? self.placements.delete(target_placement) next end source_placement = source_entry.placements.find(:first, :conditions => { :placement_category_id => source_category.category_id }) self.placements.delete(target_placement) if source_placement.blank? end end # Comments need to be synchronized separately (should always flow from production -> beta). end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def synchronize(mapping)\n Synchronizer.new(mapping).run(@changes)\n end", "def synchronize!(updater); end", "def synchronize(updater); end", "def sync(&b)\n @m.synchronize &b\n end", "def sync!(source_entry)\n self.sync(source_entry)\n self.save\n end", "de...
[ "0.6122481", "0.6055316", "0.60074204", "0.58032995", "0.57928747", "0.57697976", "0.57101095", "0.5604349", "0.549776", "0.53674805", "0.53674805", "0.53674805", "0.5356839", "0.53225935", "0.53107023", "0.5242395", "0.5230273", "0.5228308", "0.5225348", "0.5205619", "0.5205...
0.5254652
15
Synchronize this entry with the given entry's values and save.
def sync!(source_entry) self.sync(source_entry) self.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def synchronize!(updater); end", "def sync\n object.save\n end", "def save\n if modified? and @entries and !@entries.empty?\n save!\n end\n end", "def commit\n @read_lock.synchronize do\n @write_lock.synchronize do\n unless @saved\n storage.store(self.c...
[ "0.6049968", "0.6043856", "0.59896356", "0.58984125", "0.5821936", "0.579033", "0.573164", "0.5724325", "0.57190114", "0.56528705", "0.56422573", "0.56369364", "0.5555647", "0.5547103", "0.5514507", "0.5510182", "0.5510182", "0.5510182", "0.55010307", "0.5470768", "0.544229",...
0.65741855
0
Determine if this entry has been tagged with ANY of the given categories. Accepts a single Category instance or an Array of Category instances.
def has_category?(target_categories) target_categories = [ target_categories ] if target_categories.class == Category target_categories.each do |target_category| placement = MovableType::AR::Placement.find(:first, :conditions => { :placement_blog_id => self.entry_blog_id, :placement_entry_id => self.entry_id, :placement_category_id => target_category.category_id }) return true unless placement.blank? end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_categories?(company, *category_ids)\n return false if category_ids.empty?\n customer_category_ids = get_customer_categories(customer_id: company.id)\n customer_category_ids = as_array(customer_category_ids)\n (customer_category_ids & category_ids) == category_ids\n end", ...
[ "0.65408516", "0.639429", "0.61388236", "0.60425526", "0.5936917", "0.56868273", "0.5660266", "0.56564355", "0.5612325", "0.5605357", "0.55852157", "0.5514372", "0.55059236", "0.54927284", "0.54735523", "0.54735523", "0.5464497", "0.54365706", "0.54306704", "0.5422269", "0.54...
0.6183623
2
Determine if this entry has been tagged with ALL of the given categories. Accepts a single Category instance or an Array of Category instances.
def has_categories?(target_categories) target_categories = [ target_categories ] if target_categories.class == Category target_categories.each do |target_category| placement = MovableType::AR::Placement.find(:first, :conditions => { :placement_blog_id => self.entry_blog_id, :placement_entry_id => self.entry_id, :placement_category_id => target_category.category_id }) return false if placement.blank? end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_categories?(company, *category_ids)\n return false if category_ids.empty?\n customer_category_ids = get_customer_categories(customer_id: company.id)\n customer_category_ids = as_array(customer_category_ids)\n (customer_category_ids & category_ids) == category_ids\n end", ...
[ "0.620547", "0.5969582", "0.57548946", "0.5728568", "0.5728568", "0.5723821", "0.55739635", "0.55209726", "0.5515366", "0.54984766", "0.54556", "0.54425", "0.5437731", "0.5416453", "0.5416453", "0.54082465", "0.5404621", "0.5400017", "0.5262817", "0.52502406", "0.5243922", ...
0.6077364
1
Determine if this entry is more recently modified than the given entry.
def more_recently_modified?(target_entry) self.entry_modified_on > target_entry.entry_modified_on end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def more_recently_modified?(target_template)\n self.template_modified_on > target_template.template_modified_on\n end", "def modified_since?( time )\n mtime > time\n end", "def content_changed_since?(last_updated)\n stale?(:last_modified => last_updated)\n end", "def updated_since?(time)\...
[ "0.73516905", "0.730385", "0.6992701", "0.6969183", "0.6820048", "0.66662467", "0.6606912", "0.6589553", "0.6522326", "0.649756", "0.64491946", "0.64491946", "0.6413606", "0.63790387", "0.63375", "0.62930477", "0.6282244", "0.6273568", "0.6262534", "0.62536937", "0.62317723",...
0.86451054
0
Entry Status Codes: 1 Unpublished, 2 Published, 4 Scheduled
def status_string case self.entry_status when 1: 'Draft' when 2: 'Publish' when 4: 'Scheduled' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def publish_status_for(m)\n s = if m.upcoming?\n :upcoming\n elsif m.expired?\n :expired\n elsif m.published?\n :published\n else\n :draft\n end\n end", "def statuses\n statuses = {\n \"Not started\" => 1,\n \"In Progress\" => 2,\n \"Finished\" => 3\n }\n ...
[ "0.6768068", "0.67153543", "0.65673023", "0.6517379", "0.6441541", "0.631587", "0.63074005", "0.62611413", "0.6230088", "0.6216113", "0.6131468", "0.61275834", "0.61082035", "0.6093529", "0.60713404", "0.60582864", "0.6032736", "0.6029489", "0.6020446", "0.6019723", "0.601384...
0.7870409
0
Output a string representation of the entry. In this case, we're outputting the MT3.2 export format.
def to_s output = 'AUTHOR: ' + self.author.author_name + "\n" + 'TITLE: ' + self.entry_title + "\n" + 'STATUS: ' + self.status_string + "\n" + 'ALLOW COMMENTS: ' + self.entry_allow_comments.to_s + "\n" + 'CONVERT BREAKS: ' + self.entry_convert_breaks + "\n" + 'ALLOW PINGS: ' + self.entry_allow_pings.to_s + "\n\n" + 'DATE: ' + self.entry_created_on.strftime(EXPORT_DATE_FORMAT) + "\n" + EXPORT_ATTRIBUTE_BREAK output += 'BODY:' + "\n" output += self.entry_text.blank? ? "\n" : self.entry_text.chomp + "\n\n" output += EXPORT_ATTRIBUTE_BREAK output += 'EXTENDED BODY:' + "\n" output += self.entry_text_more.blank? ? "\n" : self.entry_text_more.chomp + "\n\n" output += EXPORT_ATTRIBUTE_BREAK output += 'EXCERPT:' + "\n" output += self.entry_excerpt.blank? ? "\n" : self.entry_excerpt.chomp + "\n\n" output += EXPORT_ATTRIBUTE_BREAK output += 'KEYWORDS:' + "\n" output += self.entry_keywords.blank? ? "\n" : self.entry_keywords.chomp + "\n\n" output += EXPORT_ATTRIBUTE_BREAK # Append comments. output += self.comments.collect { |comment| comment.to_s }.join output += EXPORT_ENTRY_BREAK output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entry_to_str(entry)\n entry.to_s\n end", "def put_entry(entry)\n @io.puts EntryFormatter.new(entry)\n end", "def to_s\n TEXT_SYMBOLS[self.entry_type] + \n \"] \" +\n body\n end", "def to_s\n str = \"Level: #{@level}\\n\"\\\n \"Entries:\\n\"\n str <...
[ "0.68857336", "0.6766608", "0.66217965", "0.6489307", "0.642953", "0.6378364", "0.62952757", "0.6266703", "0.6149705", "0.61031", "0.6035086", "0.6021144", "0.5974703", "0.5961773", "0.5945506", "0.5928209", "0.59155846", "0.59111625", "0.58853734", "0.5816403", "0.5804448", ...
0.7363025
0
An array of information that uniquely identifies this object.
def unique_info [ self.blog.blog_name, self.entry_title ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_identifiers\n [:name, :path]\n end", "def identities\n \n return ::IdentifiesAs.object_identities( self ) \n \n end", "def object_identifier\n [\"#{self.class.name}\", (id.nil? ? nil : \"##{id}\"), \":0x#{self.object_id.to_s(16)}\"].join\n end", "def hash\n obje...
[ "0.7100493", "0.68489105", "0.66621304", "0.65797657", "0.6396729", "0.62763655", "0.62762034", "0.62481725", "0.62474006", "0.6222934", "0.61811095", "0.612043", "0.6117298", "0.60796285", "0.6072154", "0.6023321", "0.59588706", "0.59588706", "0.59450436", "0.5914293", "0.59...
0.6052617
15
GET /api/member/inflows GET /api/member/inflows.json
def index @pagination = nil build do message 'Список поступлений' path member_inflows_path @transactions = paginate current_user.inflows.order('updated_at DESC') view 'member/inflows/index' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @inflows = Inflow.all\n end", "def get_flows()\n\tputs \"Getting flows\"\n\tresponse = request_get('/api/partner/flow')\n\tputs response.body\nend", "def set_inflow\n @inflow = Inflow.find(params[:id])\n end", "def show\n @finance_inflow = FinanceInflow.find(params[:id])\n\n res...
[ "0.7178731", "0.6371169", "0.6078823", "0.6050124", "0.595254", "0.59095466", "0.58044094", "0.5801477", "0.5774401", "0.5737059", "0.5631648", "0.562213", "0.5617938", "0.5611206", "0.5611206", "0.5611206", "0.5611206", "0.5611206", "0.56029814", "0.5595435", "0.55850047", ...
0.71516466
1
GET /api/member/inflows/1 GET /api/member/inflows/1.json
def show build do message 'Платеж детально' view 'member/transactions/show' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @inflows = Inflow.all\n end", "def index\n @pagination = nil\n\n build do\n message 'Список поступлений'\n path member_inflows_path\n @transactions = paginate current_user.inflows.order('updated_at DESC')\n view 'member/inflows/index'\n end\n end", "def get_flows()...
[ "0.7266855", "0.7115027", "0.64408785", "0.63229936", "0.6271196", "0.5954466", "0.5863644", "0.58218896", "0.5820168", "0.5743527", "0.5734539", "0.57042843", "0.56683946", "0.56430244", "0.5634156", "0.5634156", "0.5634156", "0.5634156", "0.5631919", "0.56231093", "0.562310...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_transaction @transaction = Transaction.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def transaction_params params.require(:transaction).permit(:from_id, :to_id, :amount, :ask_id, :order_id, :status) #params.require(:transaction).permit(:ask_id, :status) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
Encodes the given integer
def encode i return @sequence[0,1] if i == 0 s = '' while i > 0 s << @sequence[i.modulo(@base)] i /= @base end s.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_int8(int)\n write([int].pack(\"C\"))\n end", "def encode_varint(i)\n raise ArgumentError, \"int must be present\" if !i\n raise ArgumentError, \"int must be non-negative\" if i < 0\n\n buf = if i < 0xfd\n [i].pack(\"C\")\n elsif i <= 0xffff\n [0xfd, i].pac...
[ "0.7188605", "0.71463454", "0.7050034", "0.69769615", "0.69019634", "0.6836921", "0.6829588", "0.681511", "0.6799687", "0.678987", "0.67177624", "0.6646999", "0.65775007", "0.6572836", "0.6550743", "0.6518014", "0.646883", "0.64592266", "0.64498734", "0.64163285", "0.6408367"...
0.6641103
12
Decodes the given string
def decode s i = 0 s.each_char { |c| i = i * @base + @sequence.index(c) } i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_string(str)\n\nend", "def decode(string)\n Marshal.load(string.unpack('m').first)\n end", "def decode(text); end", "def decode(string, options = {})\n engine.decode(string, options)\n rescue engine::ParseError => exception\n raise DecodeError, exception.message, exception.backtrace\...
[ "0.8077246", "0.80513763", "0.75516576", "0.7525819", "0.73345405", "0.72830534", "0.7236038", "0.70363647", "0.7001754", "0.6930223", "0.69281334", "0.69232976", "0.6915478", "0.6901953", "0.6901471", "0.6901471", "0.6858696", "0.6830207", "0.6827045", "0.6793606", "0.679360...
0.59374416
78
user will be saved only if passwords match
def password=(password) @password = password self.password_digest = BCrypt::Password.create(password) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save\r\n if valid_password?\r\n super\r\n else\r\n false\r\n end\r\n end", "def save\n return false unless valid?\n\n call_ok?(:maintain_user, forgot_password_request)\n end", "def encode_password?(myuser, password, password_confirmation)\n\n if password.length>=@@minimum_pass...
[ "0.7713417", "0.72116363", "0.71559936", "0.7035309", "0.7034763", "0.70226127", "0.7014927", "0.70018405", "0.6980558", "0.69468063", "0.69457746", "0.692354", "0.6895469", "0.684304", "0.68019223", "0.6740659", "0.67154986", "0.66926855", "0.6689747", "0.6659968", "0.662418...
0.0
-1
GET /phone/activities GET /phone/activities.json
def index @activity = Activity.new @user = current_user @restaraunts = ["100M省内流量包", "谢谢参与", "谢谢参与", "谢谢参与", "10M免费流量包", "20M免费流量包", "谢谢参与 ", "30M免费流量包", "100M免费流量包", "谢谢参与"] @colors = ["#FFF4D6", "#FFFFFF", "#FFF4D6", "#FFFFFF","#FFF4D6", "#FFFFFF", "#FFF4D6", "#FFFFFF","#FFF4D6", "#FFFFFF"]; #活动ID # @activity_id = params[:activity_id] # unless @activity_id.blank? # @activity = Activity.find(@activity_id) # @activity_awards = @activity.activity_awards.where("status='00A'") # @restaraunts = [] # @activity_awards.each do |award| # @activity_award_cfg = ActivityAwardCfg.find(award.activity_award_cfg_id) # @restaraunts.push(@activity_award_cfg.name) # end # end #只有唯一有效 @activity = Activity.where("status='00A'").first @activity_awards = @activity.activity_awards.where("status='00A'") @restaraunts = [] @restaraunts_idx = ["一","二","三","四","五","六","七","八","九","十"] @activity_awards.each_with_index do |award,index| @activity_award_cfg = ActivityAwardCfg.find(award.activity_award_cfg_id) @restaraunts.push(award.catalog+"#"+@activity_award_cfg.name) end #抽奖次数 #has_draw = @user.lotteries.where("created_at >= ?", Time.now.beginning_of_day).size #@avaliable = Const::CHANCE_DRAE_COUNT.to_i - has_draw #按消耗决定抽奖次数 #@avaliable = @user.score / Const::SCORE_COST.to_i $config_info.each do |c| if c.cf_id == "ACTIVITY_SCORE_COST" @cost = c.cf_value.to_i end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activities\n get_call(\"1/activities.json\")\n end", "def activities(options={})\n response = connection.get do |req|\n req.url \"activities\", options\n end\n return_error_or_body(response)\n end", "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def ...
[ "0.849015", "0.76954573", "0.76930046", "0.76930046", "0.7580957", "0.7565212", "0.7487615", "0.7481385", "0.73289853", "0.7274799", "0.7196997", "0.7090325", "0.70509684", "0.70201117", "0.7003895", "0.7000405", "0.69839853", "0.6935453", "0.6934584", "0.68540263", "0.685402...
0.0
-1
GET /phone/activities/1 GET /phone/activities/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activities\n get_call(\"1/activities.json\")\n end", "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def activity(id)\n get(\"/activities/#{id}.json\")\n end", "def recent_activities\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def recent_act...
[ "0.799732", "0.78788334", "0.78788334", "0.7325458", "0.7231403", "0.72079825", "0.7181869", "0.71538424", "0.71485925", "0.7147371", "0.71142066", "0.7064638", "0.6969923", "0.6967385", "0.6949871", "0.68792206", "0.68792206", "0.6824173", "0.6822082", "0.68067527", "0.67913...
0.0
-1
POST /phone/activities POST /phone/activities.json
def create @activity = Activity.new(activity_params) respond_to do |format| if @activity.save format.html { redirect_to [:phone, @activity], notice: 'Activity was successfully created.' } format.json { render action: 'show', status: :created, location: @activity } else format.html { render action: 'new' } format.json { render json: @activity.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @activity = @user.activities.create(activity_params)\n\n respond_to do |format|\n if @activity.save\n format.html { redirect_to @activity, notice: 'Exercise event was successfully created.' }\n format.json { render :show, status: :created, location: @activity }\n else\n ...
[ "0.6851622", "0.6782767", "0.67195725", "0.67097855", "0.6677843", "0.6623596", "0.6619132", "0.66157347", "0.6611151", "0.65531725", "0.65399796", "0.65394914", "0.65394914", "0.6520622", "0.65198267", "0.64781284", "0.64236987", "0.64203644", "0.6404976", "0.64016384", "0.6...
0.6985023
0
PATCH/PUT /phone/activities/1 PATCH/PUT /phone/activities/1.json
def update respond_to do |format| if @activity.update(activity_params) format.html { redirect_to [:phone, @activity], notice: 'Activity was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @activity.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @activity = Activity.find(params[:id])\n\n respond_to do |format|\n if @activity.update_attributes(params[:activity])\n format.html { redirect_to @activity, notice: 'Activity was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render acti...
[ "0.6621953", "0.6618322", "0.65874785", "0.6585369", "0.65725636", "0.65600497", "0.6496334", "0.6496334", "0.6496334", "0.6496334", "0.6496334", "0.64784133", "0.6452255", "0.6439548", "0.6433706", "0.6410258", "0.6410258", "0.6410258", "0.6376564", "0.6363179", "0.6342682",...
0.6997206
0
DELETE /phone/activities/1 DELETE /phone/activities/1.json
def destroy @activity.destroy respond_to do |format| format.html { redirect_to phone_activities_url, notice: 'Activity was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n\n if @activity.nil?\n send_error_json(nil, \"Delete error\", 400)\n return\n end\n\n currid = @activity.id\n\n if @activity.destroy\n send_success_json(currid, {})\n else\n send_error_json(currid, \"Delete error\", 400)\n end\n end", "def destroy\n @activit...
[ "0.7360123", "0.72231245", "0.71947044", "0.71844614", "0.71844614", "0.7182956", "0.7182956", "0.7182956", "0.7182956", "0.7182956", "0.7165239", "0.7165239", "0.7126571", "0.7091466", "0.70027685", "0.6991536", "0.69645506", "0.690256", "0.6896245", "0.68606234", "0.6860623...
0.7387664
0
Use callbacks to share common setup or constraints between actions.
def set_activity @activity = Activity.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def activity_params params[:activity] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Connect user to apartment If user doesn't exist, create user POST /connect
def connect @user = User.where(:email => params[:user][:email]).first # If there is no user, create one if @user.nil? then @user = User.new(user_params) end authorize @user @user.apartment_id = params[:user][:apartment_id] respond_to do |format| if @user.save! format.html { redirect_to @user, notice: 'User was successfully connected.' } format.json { render :show, status: :connected, location: @user } else format.html { render :new } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user_and_login \n\t\tinsert_into :users, {\n\t\t\tid: 1 ,\n\t\t\tfirst_name: 'First',\n\t\t\tlast_name: 'Last',\n\t\t\tlogin: 'login',\n\t\t\tpassword: 'password',\n\t\t\trole_id: 1,\n\t\t\tuid: \"a\"\n\t\t}\n\n\t\tproxy.post( 'http://my.ownet/api/session',{\n\t\t\tlogin: 'login',\n\t\t\tpassword: 'pass...
[ "0.69022894", "0.6717939", "0.65746754", "0.6515578", "0.6509765", "0.64927495", "0.6457831", "0.6399128", "0.6340649", "0.63166904", "0.6308005", "0.63002175", "0.62975883", "0.6285958", "0.62838274", "0.6274411", "0.6273143", "0.6262133", "0.62559867", "0.62468296", "0.6246...
0.7948953
0
Never trust parameters from the scary internet, only allow the white list through.
def user_params params.require(:user).permit(:password, :email, :last_name, :first_name, :mobile, :phone, :apartment_id, :password_confirmation, :user_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
, :startdate, :finishdate before_save :check_dates def check_dates return false if self.startdate > self.finishdate if self.startdate > self.finishdate raise ActiveRecord::RecordNotSaved, 'Starting date must precede finishing date' end end
def get_site_zipcodes zipcodes = [] self.sites.each do |site| # zipcodes << site.get_zipcode zipcodes << site.zipcode end return zipcodes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def date_validation\n\t\tif start_date >= end_date\n \t\terrors.add(:end_date, \"must be greater than start date\")\n \tend\n end", "def reservation_dates_must_make_sense\n\t if end_date <= start_date\n\t\t errors.add(:start_date, \"has to be before the end date\")\n\t end\n\tend", "def start_...
[ "0.78743166", "0.7729525", "0.76688856", "0.7586131", "0.75481564", "0.7480169", "0.7400195", "0.73684883", "0.73684883", "0.7359981", "0.7297662", "0.7297662", "0.7236243", "0.7229029", "0.7223893", "0.7222331", "0.71729565", "0.7170478", "0.71576816", "0.71549696", "0.71501...
0.0
-1
Returns first found cycle from one cell to another. from and to should be in the same row or column. Actually returns chain that's longer than 3 cells
def find(from, to) return unless valid_start_end?(from, to) horiz_traverse = go_horizontal(from, to) return horiz_traverse if valid_cycle?(horiz_traverse) vert_traverse = go_vertical(from, to) return vert_traverse if valid_cycle?(vert_traverse) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_any(from)\n (cells_set.all_row_neighbours(from) + cells_set.all_col_neighbours(from)).each do |cell_end|\n cycle = find(from, cell_end)\n return cycle if cycle\n end\n end", "def knight_path(from, to)\n\topen_queue = [PositionPath.new( from, [copy(from)] )]\n\tdiscovered = [fr...
[ "0.622102", "0.54713285", "0.5357408", "0.53493273", "0.5343701", "0.53069687", "0.5279735", "0.52044594", "0.51849943", "0.5178869", "0.51762915", "0.5133679", "0.5111242", "0.50902766", "0.50835955", "0.50675124", "0.5032169", "0.50316614", "0.5026667", "0.5025015", "0.5019...
0.5935414
1
If they are in the same row or column
def raise_if_invalid_start_end(from, to) unless valid_start_end?(from, to) raise ArgumentError, "#{from} and #{to} can't be a start and end of cycle!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def share_item?(cell)\n row == cell.row || column == cell.column\n end", "def identical_symbols(row_or_column)\n row_or_column[0] * 3 == row_or_column\n end", "def squarocol?(grid)\n return true if grid.any? { |row| row.uniq.length == 1 }\n return true if grid.transpose.any? { |col| col.uniq....
[ "0.7191228", "0.71197957", "0.7090915", "0.7090915", "0.70362633", "0.6962402", "0.69100124", "0.68198323", "0.6807067", "0.6788327", "0.6788327", "0.6710709", "0.6665885", "0.6622408", "0.6622408", "0.65635103", "0.65618324", "0.65579927", "0.6543215", "0.6528465", "0.651664...
0.0
-1
cycle starting at from and ending at any cell
def find_any(from) (cells_set.all_row_neighbours(from) + cells_set.all_col_neighbours(from)).each do |cell_end| cycle = find(from, cell_end) return cycle if cycle end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cycle!\n cells_to_die = []\n cells_to_be_born = []\n # Iterates through all possible fields of the life surface\n width.times do |x|\n height.times do |y|\n current_cell = cells.find_cell(x,y)\n if current_cell.dead?\n #Any dead cell with exactly three live neighbours be...
[ "0.62494975", "0.61108255", "0.59519196", "0.5906068", "0.58460665", "0.58170635", "0.579092", "0.5782643", "0.575292", "0.5688336", "0.5688336", "0.5688336", "0.5665605", "0.5656582", "0.5627673", "0.5592239", "0.5591153", "0.557279", "0.55722433", "0.55706537", "0.55579525"...
0.0
-1
new method: chain_skill_restriction? tag: modified tag: skill
def chain_skill_restriction?(skill) #return false unless actor? return false unless $game_party.in_battle return false unless skill.chain_only return false if (self.state?(90) || self.state?(288)) && skill.is_spell? return !@active_chain_enabled end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skill_effect(user, skill)\n # Clear critical flag\n self.critical = false\n # If skill scope is for ally with 1 or more HP, and your own HP = 0,\n # or skill scope is for ally with 0, and your own HP = 1 or more\n if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or\n ((skill.sc...
[ "0.6622267", "0.6621239", "0.64674276", "0.6382901", "0.6310718", "0.630359", "0.6173509", "0.61638504", "0.61558837", "0.6150064", "0.61482567", "0.61196035", "0.6110599", "0.6097777", "0.6076968", "0.6059845", "0.6046826", "0.6002369", "0.60013384", "0.59988534", "0.5984860...
0.7818729
0
GET /resource/sign_up def new super end POST /resource def create super end GET /resource/edit def edit super end PUT /resource def update p "registrations controller update user params" p params[:user] super end
def update @user = User.find(current_user.id) # email_changed = @user.email != params[:user][:email] is_facebook_account = !@user.provider.blank? successfully_updated = if !is_facebook_account @user.update_with_password(allowed_params) else @user.update_without_password(allowed_params) end if successfully_updated # Sign in the user bypassing validation in case his password changed # sign_in @user, :bypass => true redirect_to registration_path else redirect_to registration_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n build_resource(sign_up_params)\n\n respond_to do |format|\n if resource.save\n format.html { redirect_to admin_root_path, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { rende...
[ "0.70590264", "0.69016117", "0.6775044", "0.6734895", "0.6709172", "0.6689862", "0.66662043", "0.6664463", "0.6636868", "0.66352373", "0.6627205", "0.66199595", "0.65824425", "0.65624714", "0.6542991", "0.6530316", "0.6530264", "0.65057176", "0.6504131", "0.64880264", "0.6481...
0.0
-1
DELETE /resource def destroy super end GET /resource/cancel Forces the session data which is usually expired after sign in to be expired now. This is useful if the user wants to cancel oauth signing in/up in the middle of the process, removing all OAuth session data. def cancel super end protected If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute]) devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :current_password, :names, :surnames, :area_of_residence_id, :area_of_interest_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end", "def cancel\n expire_session_data_after_sign_in!\n redirect_to new_registrat...
[ "0.7433806", "0.7433806", "0.7433806", "0.7433806", "0.7433806", "0.7433806", "0.72670454", "0.72670454", "0.72670454", "0.72670454", "0.72670454", "0.72670454", "0.72670454", "0.72383803", "0.70399714", "0.69377154", "0.6936114", "0.69331074", "0.69171745", "0.6906021", "0.6...
0.0
-1
If you have extra params to permit, append them to the sanitizer.
def configure_account_update_params devise_parameter_sanitizer.permit(:account_update) do |user_params| user_params.permit(:email, :password, :password_confirmation, :current_password, :names, :surnames, :area_of_residence_id, :area_of_interest_id) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindat...
[ "0.6904302", "0.68366474", "0.6828931", "0.67895484", "0.6674864", "0.66533923", "0.66445297", "0.6596151", "0.6560917", "0.6493841", "0.64901817", "0.6478389", "0.6449164", "0.6439775", "0.6419462", "0.64191973", "0.63998723", "0.63986796", "0.63986796", "0.6394532", "0.6381...
0.0
-1
Parses the given byte buffer and populate the result object. Returns the number of bytes that were parsed from the given buffer.
def parse_record(key, op_count, generation, expiration) bins = op_count > 0 ? {} : nil i = 0 while i < op_count raise Aerospike::Exceptions::QueryTerminated.new unless valid? read_bytes(8) op_size = @data_buffer.read_int32(0).ord particle_type = @data_buffer.read(5).ord name_size = @data_buffer.read(7).ord read_bytes(name_size) name = @data_buffer.read(0, name_size).force_encoding('utf-8') particle_bytes_size = op_size - (4 + name_size) read_bytes(particle_bytes_size) value = Aerospike.bytes_to_particle(particle_type, @data_buffer, 0, particle_bytes_size) bins[name] = value i = i.succ end Record.new(@node, key, bins, generation, expiration) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(data)\n return 0 unless data && data.bytesize > 0\n if data.bytesize < @bytes_expected\n @buffer << data\n @bytes_expected -= data.bytesize\n return data.bytesize\n else\n @buffer << data[0..@bytes_expected]\n bytes_parsed ...
[ "0.6718551", "0.6137891", "0.6135124", "0.6090458", "0.6009005", "0.6009005", "0.6009005", "0.5960701", "0.59458745", "0.5916602", "0.5754258", "0.57157916", "0.5672201", "0.5628341", "0.5584414", "0.55173004", "0.5483112", "0.54458797", "0.5434178", "0.54060537", "0.5383499"...
0.0
-1
At the moment each user only has one team later on users may have multiple teams.. this method will change to access specific teams and will likely take parameters.
def my_team self.teams.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def give_access_to_teams\n teams.includes(:users).each do |team|\n team.users.each do |user|\n user.set_access_to_app(self, team.id)\n end\n end\n end", "def with_access_to_teams_with_any_role\n if c_level?\n organization.teams\n else\n TeamMember.includes(:team).where(use...
[ "0.74668175", "0.74360955", "0.7271779", "0.7232183", "0.72058004", "0.70978", "0.7094397", "0.7075371", "0.70665914", "0.69717735", "0.6925874", "0.6918414", "0.6872228", "0.6828475", "0.6814395", "0.6814395", "0.6806299", "0.67666614", "0.67081344", "0.6691249", "0.6681012"...
0.62397546
64
Currently each user only has one teammate. This method will change see above `my_team` method.
def teammate my_team = self.teams.first if my_team team_members = my_team.users teammate = team_members.select { |member| member.id != self.id } return teammate.first else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def teammates_for_user(user)\n team = team_for_user(user)\n team && (team.users - [user])\n end", "def current_user_team\n current_user.team\n end", "def team_for_user(user)\n membership = TeamMembership.find_by user: user, team: teams\n membership && membership.team\n end", "def current_te...
[ "0.76152205", "0.7136385", "0.705567", "0.6869717", "0.675059", "0.67491317", "0.6733842", "0.668934", "0.6666518", "0.65078527", "0.64988655", "0.64894307", "0.64882135", "0.6475296", "0.64616036", "0.6460383", "0.6412033", "0.64048755", "0.6387486", "0.6386653", "0.63356364...
0.80504394
0
Writen by Steven Bedrick and modified by Shiran Dudy
def process_article(art) this_pub = {} # if not table of figure or equation remove reference # a.zip(b) zipped lists both = art.xpath('//xref/@ref-type').zip(art.xpath('//xref')) both.each do |tag,elem| if tag.text != 'table' || tag.text != 'fig' || tag.text != 'fn' || tag.text != 'sec' || tag.text != 'disp-formula' elem.remove end end jrn_meta = art / "article/front/journal-meta" this_pub[:jrn_id] = (jrn_meta / "journal-id[journal-id-type='nlm-ta']").text art_meta = art / "/article/front/article-meta" this_pub[:pmid] = (art_meta / "article-id[pub-id-type='pmid']").text this_pub[:pmcid] = (art_meta / "article-id[pub-id-type='pmc']").text # this_pub[:doi] = (art_meta / "article-id[pub-id-type='doi']").text # title title_node = (art_meta / "title-group/article-title") # SDB Note 8/2016 # Turns out that some of the article titles include footnotes or super/subscripts which occurred at the end of a title, # which are represented by embedded tags (e.g. <fn> or something like that),and calling .text on the title node was # including those (and messing stuff up in the process). # We thought that we only needed to worry about tags at the end of titles, and so for trec CDS 2016 we just used the first child node and called it good. # This turned out to be insufficient- in the latest PMC release, there are titles with italic text (cf. PMC1079931), # and the approach below fails in these cases. # TODO: a more robust title-parsing algorithm if title_node.children.size > 1 this_pub[:title] = title_node.children.first.text.strip else this_pub[:title] = title_node.text.strip end # pub_year # if ppub, use that; else use collection ppub = (art_meta / "pub-date[pub-type='ppub']/year").text epub = (art_meta / "pub-date[pub-type='epub']/year").text year = nil if ppub.strip.length > 0 year = ppub.strip else year = epub.strip end this_pub[:year] = year # abstract (if present) abst_node = art_meta / "abstract" this_pub[:abstract] = {} if abst_node.length == 0 this_pub[:abstract][:full] = "" elsif (abst_node / "sec").size > 0 # structured abstract (inc. section headings) abstract_full = "" # go through each section, and get the parts out in some kind of order (abst_node / "sec").each do |s| # rm furmulas s.search('//p/disp-formula').each do |node| node.remove end s.search('//p/inline-formula').each do |node| node.remove end s.search('//title/disp-formula').each do |node| node.remove end s.search('//title/inline-formula').each do |node| node.remove end ti = (s / "title").text.strip body = (s / "p").text.strip # clean leftovers of xref body = body.gsub(/\(-*\)/, "") body = body.gsub(/\[,*\]/, "") body = body.gsub(/\[-*\]/, "") body = body.gsub(/\(,*\)/, "") ti = ti.gsub(/\[-*\]/, "") ti = ti.gsub(/\(,*\)/, "") ti = ti.gsub(/\(-*\)/, "") ti = ti.gsub(/\[,*\]/, "") abstract_full << ti << "\n" abstract_full << body << "\n" end this_pub[:abstract][:full] = abstract_full.strip end if (abst_node / "p").size > 0 # unstructured abstract abstract_full = this_pub[:abstract][:full].to_s (abst_node / "p").each do |s| s.search('//disp-formula').each do |node| node.remove end s.search('//inline-formula').each do |node| node.remove end abs = s.text.strip abs = abs.gsub(/\[-*\]/, "") abs = abs.gsub(/\(,*\)/, "") abs = abs.gsub(/\(-*\)/, "") abs = abs.gsub(/\[,*\]/, "") abstract_full << abs << "\n" end this_pub[:abstract][:full] = abstract_full else STDERR.puts "Other format found: " + (art_meta / "article-id[pub-id-type='pmc']").text this_pub[:abstract][:full] = "" end # now do body- similar deal this_pub[:body] = {} body_node = art / "/article/body" if (body_node / "sec").size > 0 body_full = "" (body_node / "sec").each do |s| # rm xref # rm furmulas s.search('//p/disp-formula').each do |node| node.remove end s.search('//p/inline-formula').each do |node| node.remove end s.search('//title/disp-formula').each do |node| node.remove end s.search('//title/inline-formula').each do |node| node.remove end s.search('//fig/caption/p/disp-formula').each do |node| node.remove end s.search('//fig/caption/p/inline-formula').each do |node| node.remove end s.search('//table-wrap/table-wrap-foot/p/disp-formula').each do |node| node.remove end s.search('//table-wrap/table-wrap-foot/p/inline-formula').each do |node| node.remove end s.search('//table-wrap/table-wrap-foot/fn/disp-formula').each do |node| node.remove end s.search('//table-wrap/table-wrap-foot/fn/inline-formula').each do |node| node.remove end ti = (s / "title").text.strip body = (s / "p").text.strip fig_cap = (s / "fig/caption/p").text.strip tbl_cap = (s / "table-wrap/table-wrap-foot/p").text.strip tbl_fn = (s / "table-wrap/table-wrap-foot/fn").text.strip # clean leftovers of xref ti = ti.gsub(/\[-*\]/, "") ti = ti.gsub(/\(,*\)/, "") ti = ti.gsub(/\(-*\)/, "") ti = ti.gsub(/\[,*\]/, "") body = body.gsub(/\[-*\]/, "") body = body.gsub(/\(,*\)/, "") body = body.gsub(/\(-*\)/, "") body = body.gsub(/\[,*\]/, "") fig_cap = fig_cap.gsub(/\[-*\]/, "") fig_cap = fig_cap.gsub(/\(,*\)/, "") fig_cap = fig_cap.gsub(/\(-*\)/, "") fig_cap = fig_cap.gsub(/\[,*\]/, "") tbl_cap = tbl_cap.gsub(/\[-*\]/, "") tbl_cap = tbl_cap.gsub(/\(,*\)/, "") tbl_cap = tbl_cap.gsub(/\(-*\)/, "") tbl_cap = tbl_cap.gsub(/\[,*\]/, "") tbl_fn = tbl_fn.gsub(/\[-*\]/, "") tbl_fn = tbl_fn.gsub(/\(,*\)/, "") tbl_fn = tbl_fn.gsub(/\(-*\)/, "") tbl_fn = tbl_fn.gsub(/\[,*\]/, "") body_full << ti << "\n" body_full << body << "\n" body_full << fig_cap << "\n" body_full << tbl_cap << "\n" body_full << tbl_fn << "\n" end this_pub[:body][:full] = body_full.strip end if (body_node / "p").size > 0 # found the sec and p can coexist 2660466.nxml body_full = this_pub[:body][:full].to_s (body_node / "p").each do |s| s.search('//disp-formula').each do |node| node.remove end s.search('//inline-formula').each do |node| node.remove end body = s.text.strip body = body.gsub(/\[-*\]/, "") body = body.gsub(/\(,*\)/, "") body = body.gsub(/\(-*\)/, "") body = body.gsub(/\[,*\]/, "") body_full << body << "\n" end this_pub[:body][:full] = body_full else STDERR.puts "Serious weirdness in body: "+ (art_meta / "article-id[pub-id-type='pmc']").text end return this_pub end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def formation; end", "def schubert; end", "def probers; end", "def stderrs; end", "def terpene; end", "def berlioz; end", "def trd; end", "def malts; end", "def suivre; end", "def verdi; end", "def anchored; end", "def transformations; end", "def rassoc(p0) end", "de...
[ "0.6468657", "0.6273403", "0.6158538", "0.6045643", "0.60108995", "0.5771394", "0.57477915", "0.5733995", "0.5621352", "0.5598868", "0.5590184", "0.5576884", "0.55731297", "0.556194", "0.5516677", "0.5516677", "0.5516677", "0.5516677", "0.54529226", "0.54158384", "0.5398396",...
0.0
-1
Note that this method presumes there is only one applicable search It may need to be refactored if we decide to connect multiple searches to an author exhibit
def search @search ||= exhibit.searches.first # @searches ||= exhibit.searches.published.where(slug: item_ids).sort do |a, b| # order.index(a.slug) <=> order.index(b.slug) # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def searchauthor\n end", "def authoringredientrecipesearch\n @query = params[:search]\n @searchedingredients = params[:searchingredients].split(/, */)\n @searchtest = []\n @searchedingredients.each do |si|\n @searchtest.push(si.downcase)\n end\n \n Ingredient.where(\"lower(name) IN (:s...
[ "0.7035574", "0.6479366", "0.641468", "0.6364998", "0.6359661", "0.6321539", "0.6276857", "0.61863446", "0.6184667", "0.61144066", "0.6089257", "0.6086392", "0.60618037", "0.6058401", "0.60430676", "0.60430676", "0.60430676", "0.60430676", "0.60430676", "0.60430676", "0.60430...
0.65507686
1
time complexity is either O(n^2)
def my_min2(arr) smallest = arr[0] arr[1..-1].each do |el| smallest = el if el < smallest end smallest end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))...
[ "0.7019063", "0.6983869", "0.6491422", "0.64679813", "0.64543825", "0.64400613", "0.64166856", "0.6407197", "0.63642037", "0.63239634", "0.6269182", "0.6258044", "0.6218544", "0.6205151", "0.6200739", "0.6199411", "0.61947286", "0.6170596", "0.616751", "0.6162657", "0.6146728...
0.0
-1
time complexity O(n) list = [ 0, 3, 5, 4, 5, 10, 1, 90 ] p my_min2(list)
def largest_contiguous_subsum(arr) result = [] arr.each_with_index do |el1, idx1| i = idx1 while i < arr.length result << arr[idx1..i] i += 1 end end largest_sum = result.first.inject(:+) result.each do |sub_arr| curr_sum = sub_arr.inject(:+) largest_sum = curr_sum if curr_sum > largest_sum end largest_sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_min_2(list) # n\n min_value = list.first\n i = 0\n while i < list.length\n min_value = list[i] if list[i] < min_value\n i += 1\n end\n min_value\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n ...
[ "0.8506777", "0.8432532", "0.8368096", "0.8297099", "0.823822", "0.8233083", "0.8211751", "0.8196542", "0.81564575", "0.81444126", "0.8137453", "0.81262624", "0.81256014", "0.8116775", "0.8099196", "0.8079639", "0.8064212", "0.80432165", "0.80148154", "0.8011685", "0.80037755...
0.0
-1
Sets attributes from a hash. Example: pokemon.assign_attributes(pokemon_number: 25, name: 'Pikachu')
def assign_attributes(**attributes) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_attributes(hash)\n hash.each { |k, v| send(\"#{k}=\", v) }\n end", "def assign_attributes(**attributes)\n attributes.each do |key, value|\n send(\"#{key}=\", value)\n end\n end", "def attributes=(hash)\n return unless hash\n\n hash.transform_keys { |key| \"#{key}=\".to_...
[ "0.82302046", "0.732806", "0.72201043", "0.7191058", "0.71810925", "0.71423167", "0.7064619", "0.70309234", "0.6956015", "0.68993056", "0.68724513", "0.6783554", "0.67118096", "0.667639", "0.66594124", "0.6646172", "0.6641345", "0.66409755", "0.6624514", "0.6612943", "0.66057...
0.6867413
11
Updates attributes and saves the record. Updates and .save.
def update(...) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(...)\n assign_attributes(...)\n save\n end", "def update_attributes(_params)\n assign_attributes _params\n save\n end", "def update(params)\n self.attributes = params\n save\n end", "def update(params)\n self.attributes = params\n save\n end", "def update_attrib...
[ "0.79100025", "0.7846043", "0.77877015", "0.77877015", "0.77868974", "0.7737032", "0.76986486", "0.76983577", "0.76477665", "0.7639863", "0.7639863", "0.7639863", "0.7639863", "0.7612695", "0.7612695", "0.7612695", "0.75332075", "0.7530033", "0.7522604", "0.75016487", "0.7481...
0.0
-1
Ensures instances that have the same attributes are the same.
def <=>(other) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def same_attributes?(spec)\n @@attributes.all? {|name, default| self.send(name) == spec.send(name) }\n end", "def sync_duplicate_obj_attributes(obj1, obj2)\n duplicate_keys.each do |key|\n unless obj1[key].blank? && obj2[key].blank?\n if obj1[key].blank?\n obj1.send(\"#{key}=\...
[ "0.66319764", "0.65128857", "0.649858", "0.6444392", "0.6362604", "0.63315135", "0.63217765", "0.630219", "0.62901384", "0.62900335", "0.6212902", "0.62120163", "0.6158965", "0.6128214", "0.6064453", "0.6057049", "0.604408", "0.60157496", "0.59930694", "0.5990842", "0.5962032...
0.0
-1
f = "" string.each_byte do |c| unless c == 32 c += key end if c > 122 c = 122 end f += c.chr end f end puts chiffre_de_cesar("le chiffre de cesar", 10)
def caesar_cipher(string, shift = 1) alphabet = Array('a'..'z') non_caps = Hash[alphabet.zip(alphabet.rotate(shift))] alphabet = Array('A'..'Z') caps = Hash[alphabet.zip(alphabet.rotate(shift))] encrypter = non_caps.merge(caps) string.chars.map { |c| encrypter.fetch(c, c) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crypt(text,key,operator = :+)\n index = 0\n text.upcase.each_byte.reduce(\"\") do |res, c|\n res << (65 + (c.send(operator, key[index % key.length].ord)) % 26).chr\n index += 1\n res\n end\nend", "def vigenere(key, txt)\n shift_array = key.get_shift\n count = 0\n\n txt_array ...
[ "0.7633797", "0.75632393", "0.7325879", "0.7279461", "0.7248672", "0.72446173", "0.72013223", "0.7184438", "0.7134994", "0.71205294", "0.7062146", "0.70564705", "0.7041922", "0.7033451", "0.6991934", "0.69826853", "0.69698894", "0.69547135", "0.6946546", "0.69398206", "0.6933...
0.0
-1
Params should be the HTTP query parameters as a symbolized Hash, but can/should include: :snip => the name of the snip [REQUIRED] :part => the part of the snip to show [OPTIONAL] :format => the format to render [OPTIONAL] :method => GET/POST/DELETE/PUT [OPTIONAL] Returns a Rack::Response object
def present output = case request.format when 'html', nil Renderers::Erb.new(self).render(Vanilla.snip('system'), :main_template) when 'raw' Renderers::Raw.new(self).render(request.snip, request.part || :content) when 'text' render(request.snip, request.part || :content) else "Unknown format '#{request.format}'" end @response.write(output) @response.finish end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(env)\n request = Request.new(env) \n snip, part, format = request_uri_parts(request)\n if snip\n params = request.params.merge(:snip => snip, :part => part, \n :format => format, :method => request.request_method.downcase)\n [200, {\"C...
[ "0.54864967", "0.51637274", "0.51246685", "0.5110679", "0.50966734", "0.5080438", "0.50756", "0.5056674", "0.5040749", "0.49486768", "0.4933344", "0.49080697", "0.4902027", "0.4900453", "0.48784226", "0.4868735", "0.48443052", "0.4833906", "0.4813561", "0.4806826", "0.4790105...
0.0
-1
render a snip using either the renderer given, or the renderer specified by the snip's "render_as" property, or Render::Base if nothing else is given.
def render(snip, part=:content, args=[]) rendering(snip) do |r| r.render(snip, part, args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rendering(snip)\n renderer_instance = renderer_for(snip).new(self)\n yield renderer_instance\n rescue Exception => e\n \"<pre>[Error rendering '#{snip.name}' - \\\"\" + \n e.message.gsub(\"<\", \"&lt;\").gsub(\">\", \"&gt;\") + \"\\\"]\\n\" + \n e.backtrace.join(\"\\n\").gsub(\"...
[ "0.6881654", "0.641265", "0.6204355", "0.55832493", "0.5505976", "0.5477268", "0.54039234", "0.53505576", "0.5347367", "0.53453034", "0.5312356", "0.52911335", "0.52911335", "0.52486634", "0.523482", "0.52184814", "0.5199821", "0.5165369", "0.5111018", "0.50966877", "0.509241...
0.63192415
2
Returns the renderer class for a given snip
def renderer_for(snip) return Renderers::Base unless snip.render_as Vanilla::Renderers.const_get(snip.render_as) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_renderer(name)\n begin\n class_name = name.to_s.capitalize.to_sym\n renderer = ::Hyde::Renderers.const_get(class_name)\n rescue NameError\n renderer = nil\n end\n renderer\n end", "def output_class\n 'PictureTag::OutputFormats::' + titleize(PictureTag.pres...
[ "0.61365557", "0.56887054", "0.566933", "0.55800605", "0.5526262", "0.54063183", "0.54043734", "0.53747606", "0.5357227", "0.53350115", "0.5301505", "0.52550864", "0.52149105", "0.5205534", "0.5189147", "0.5189147", "0.51730543", "0.51707566", "0.5162763", "0.5094213", "0.508...
0.76717794
0
Given the snip and parameters, yield the appropriate Vanilla::Render::Base subclass instance
def rendering(snip) renderer_instance = renderer_for(snip).new(self) yield renderer_instance rescue Exception => e "<pre>[Error rendering '#{snip.name}' - \"" + e.message.gsub("<", "&lt;").gsub(">", "&gt;") + "\"]\n" + e.backtrace.join("\n").gsub("<", "&lt;").gsub(">", "&gt;") + "</pre>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(snip, part=:content, args=[])\n rendering(snip) do |r|\n r.render(snip, part, args)\n end\n end", "def render(*args, &block); end", "def render(*)\n raise NotImplementedError.new(\"Implement a render function in a subclass\")\n end", "def render(*args); end", "def...
[ "0.6179922", "0.6147686", "0.6079971", "0.6031453", "0.6031453", "0.5979754", "0.5884259", "0.58516794", "0.57650816", "0.5714899", "0.56833076", "0.5622494", "0.5580505", "0.55482596", "0.5515118", "0.5450362", "0.5440219", "0.543981", "0.53693175", "0.5355272", "0.5323847",...
0.6217675
0
Other things can call this when a snip cannot be loaded.
def render_missing_snip(snip_name) "[snip '#{snip_name}' cannot be found]" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_error; end", "def phantom_load_raise?(e); end", "def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend", "def pre_load\n @puppet_system_loader.load(:type, 'error')\n end", "def missed_lines; end", "def missed_lines; end", "def load_er...
[ "0.6483608", "0.62891704", "0.5667479", "0.5637562", "0.5622629", "0.5622629", "0.55623746", "0.5378928", "0.537104", "0.5350572", "0.52839684", "0.5234784", "0.5219483", "0.5148978", "0.51467896", "0.50976294", "0.50962806", "0.50689733", "0.50674194", "0.50542796", "0.50444...
0.56707346
2
GET /course_programmes/1 GET /course_programmes/1.json
def show @course_programme = CourseProgramme.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @course_programme } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @course_programme = CourseProgramme.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_programme }\n end\n end", "def index\n @programs = Program.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # in...
[ "0.7265272", "0.70362693", "0.68358076", "0.6625876", "0.6625876", "0.6599125", "0.6591872", "0.6578112", "0.6550129", "0.64674205", "0.646512", "0.6463657", "0.6438181", "0.6438181", "0.6424708", "0.6387531", "0.6383348", "0.638038", "0.638038", "0.6367799", "0.6347189", "...
0.76095736
0
GET /course_programmes/new GET /course_programmes/new.json
def new @course_programme = CourseProgramme.new respond_to do |format| format.html # new.html.erb format.json { render json: @course_programme } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @program = Program.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @program }\n end\n end", "def new\n @program = Program.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @program }\n ...
[ "0.78052413", "0.78052413", "0.7619964", "0.75754976", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7559094", "0.7549545", "0.7496426", "0.7484827", "0.74783075", "0.747106", "0.74353474", "0.73982894"...
0.8105925
0
POST /course_programmes POST /course_programmes.json
def create @course_programme = CourseProgramme.new(params[:course_programme]) respond_to do |format| if @course_programme.save format.html { redirect_to @course_programme, notice: 'Course programme was successfully created.' } format.json { render json: @course_programme, status: :created, location: @course_programme } else format.html { render action: "new" } format.json { render json: @course_programme.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @course_programme = CourseProgramme.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_programme }\n end\n end", "def create\n @education_program = EducationProgram.new(education_program_params)\n\n respond_to do |format|\n if...
[ "0.691192", "0.66009915", "0.6540655", "0.64974463", "0.63949853", "0.63624114", "0.6318477", "0.630833", "0.6291437", "0.6280132", "0.626055", "0.6254252", "0.62008584", "0.61911505", "0.61903304", "0.6179712", "0.6175658", "0.61726207", "0.6171579", "0.6170537", "0.61477494...
0.74600977
0
PUT /course_programmes/1 PUT /course_programmes/1.json
def update @course_programme = CourseProgramme.find(params[:id]) respond_to do |format| if @course_programme.update_attributes(params[:course_programme]) format.html { redirect_to @course_programme, notice: 'Course programme was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @course_programme.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @education_program.update(education_program_params)\n format.html { redirect_to @education_program, notice: 'Education program was successfully updated.' }\n format.json { render :show, status: :ok, location: @education_program }\n else\n f...
[ "0.6753508", "0.6699943", "0.66820025", "0.6613048", "0.6587837", "0.65863806", "0.65637046", "0.65615064", "0.65335006", "0.65335006", "0.65333587", "0.6512236", "0.65009195", "0.649499", "0.64813626", "0.64811057", "0.6473769", "0.64699423", "0.6467917", "0.64630604", "0.64...
0.74771804
0
DELETE /course_programmes/1 DELETE /course_programmes/1.json
def destroy @course_programme = CourseProgramme.find(params[:id]) @course_programme.destroy respond_to do |format| format.html { redirect_to course_programmes_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend", "def destroy\n @education_program.destroy\n respond_to do |format|\n format.html { redire...
[ "0.72111416", "0.71724236", "0.712442", "0.7066401", "0.70383286", "0.70383286", "0.7014871", "0.69880795", "0.69764286", "0.69688976", "0.696111", "0.6945493", "0.6928646", "0.69276845", "0.6926221", "0.69256914", "0.69256914", "0.69256914", "0.69256914", "0.6921619", "0.690...
0.78058845
0
Split a WXR into smaller chunks Parse the 'premable' into memory Parse the into memory Parse the into memory for each X number of posts or size of output Create a new file Write preamble, X posts, postamble Argument is o "filename" to which is appended a .xxx.xml where xxx varys. Reads wxr from from stdin Depends on newlines in the right places. hard coded for appoximately 2MB per output file. more or less 2/20/2008 Might work it splits and Firefox doesn't complain when loading the little files. Ruby Rexml doesn't either.
def nextfile(ctr) fn = $prefix+'.'+ctr.to_s+".xml" # returns the handle h = File.new(fn,'w') $preamble.each {|ln| h.puts ln} return h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_xml(max_files = 0)\n xs = XMLSplitter.new(root_element: \"prices\", child_element: \"price\", xml_filename: \"interhome/#{xml_filename}\", elements_per_file: 2000, max_files: max_files)\n xs.split\n end", "def split_xml(max_files = 0)\n xs = XMLSplitter.new(root_element: \"vacancies\"...
[ "0.545371", "0.5393091", "0.53372276", "0.52971864", "0.52937984", "0.5265589", "0.5229972", "0.51744616", "0.5147938", "0.5002564", "0.49573398", "0.49166518", "0.48876014", "0.48876014", "0.48867193", "0.48806158", "0.485585", "0.48529944", "0.48270786", "0.48179063", "0.48...
0.4774742
25
can do this recursively to build arrays based on lowest node.
def bst_sequence(node) result = [] children_array = node.children.permutation.to_a children_array.map do |array| array.unshift(node) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend", "def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @al...
[ "0.6916019", "0.6566713", "0.6374617", "0.6373407", "0.6265868", "0.6192164", "0.61822623", "0.61796707", "0.61723167", "0.61446583", "0.61254567", "0.61218053", "0.61115247", "0.6046795", "0.6038786", "0.60146606", "0.6000675", "0.5987897", "0.59628177", "0.5946306", "0.5942...
0.0
-1
merge 2 arrays while maintaining order [0,1] [a,b] [0,1,a,b], [0,a,1,b], [0,a,b,1], [a,0,1,b], [a,b,0,1], [a,0,b,1]
def weave_array(array1, array2) result = [] idx1 = 0 idx2 = 1 while #some condition temp_array = [] while idx1 < array1.length && idx2 < array2.length if temp_array.push(array1[idx1]) idx1 += 1 end if temp_array.push(array2[idx2]) idx2 += 1 end end while idx1 < array1.length temp_array.push(array1[idx1]) idx1 += 1 end while idx2 < array2.length temp_array.push(array1[idx2]) idx2 += 1 end result.push(temp_array) end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(a, b)\n new_array = []\n i, j = 0, 0\n loop do\n if i >= a.size\n new_array << b[j..]\n break\n elsif j >= b.size\n new_array << a[i..]\n break\n elsif a[i] <= b[j]\n new_array << a[i]\n i += 1\n else\n new_array << b[j]\n j += 1\n end\n end\n n...
[ "0.73756343", "0.72732633", "0.7134336", "0.71060634", "0.70829976", "0.70219266", "0.69713694", "0.6963755", "0.6963754", "0.6939317", "0.69291604", "0.6928112", "0.6924939", "0.6923409", "0.6920669", "0.69119346", "0.6908433", "0.68786645", "0.6865207", "0.68549454", "0.685...
0.0
-1
lookup values in arrays. Table is a 2D array, where the first value is the string returned, and the following are substrings to attempt to match against the value
def tablematch(table, value) default = "" table.each do |row| rowfirst = row.first row.slice(1,row.length).each do |item| if item == "DEFAULT" # set the default value default = rowfirst elsif value.match(/^#{item}/i) #print " val: #{value} matches #{item}, returning #{rowfirst}\n" return rowfirst end end end #print " val: #{value} matches #{item}, returning #{rowfirst}\n" ##STDERR.puts "fallback on #{value}" return default end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_str(to, po)\n # final value\n s_val = []\n\n # convert into array\n t_arr = to.split('')\n p_arr = po.split('')\n\n # get the count of lookup array\n t_len = t_arr.count - 1\n p_len = p_arr.count - 1\n nxt_ctr = 0 # counter\n\n # loop at t array\n t_arr.each_with_index do |_v, i|\n # break...
[ "0.59846294", "0.5875275", "0.584506", "0.5784564", "0.5670757", "0.55634916", "0.5563353", "0.55386657", "0.5534819", "0.55337435", "0.54848516", "0.5407687", "0.5402085", "0.5389079", "0.53407496", "0.5331292", "0.5323526", "0.5318021", "0.5313146", "0.53043675", "0.529135"...
0.58741736
2
Sometimes there is only single node in DOM A quick fix would be to proceed as before if 2 nodes were found or go with the first node if only one is found
def working_items_table contract_info_tables = page.all("table.table-hover.table-bordered.table-striped", visible: true) unless contract_info_tables[1].nil? return Helpers::OpsUiHelper::TableHelper.new(node: contract_info_tables[1]) end Helpers::OpsUiHelper::TableHelper.new(node: contract_info_tables[0]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodeWithID(pageID, node)\n if node.pageID == pageID\n return node\n end\n node.childNodes.each do |childNode|\n res = nodeWithID(pageID, childNode)\n if res\n return res\n end\n end\n return nil\nend", "def next_node(html_node)\n # Hack to prevent reading empty text n...
[ "0.61073565", "0.5961845", "0.5896973", "0.58101743", "0.5735164", "0.5716208", "0.5677709", "0.5615511", "0.554949", "0.5544203", "0.5542992", "0.55312145", "0.5490416", "0.5416759", "0.54052466", "0.5394305", "0.5392493", "0.53814757", "0.53814644", "0.5378113", "0.5355901"...
0.0
-1
Returns the default SubmissionFolder for the Profile
def submission_folder submission_folders.where(is_permanent: true).first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_profile\n profiles.find_by_id(default_profile_id)\n end", "def default_folder\n self.folders.create(:name => \"LNKS!\")\n end", "def root_folder\n folders.first({ title: Folder::DefaultFolder, folder_id: nil })\n end", "def default_name\n path.dirname.basename.to_s\n end", "def ...
[ "0.5942547", "0.58648103", "0.5829539", "0.58217883", "0.57770324", "0.57489073", "0.5745176", "0.5649483", "0.5649483", "0.5649483", "0.5629696", "0.5626148", "0.56249756", "0.5589544", "0.55676615", "0.55292547", "0.5522667", "0.5520924", "0.55050695", "0.5499936", "0.54923...
0.6700724
0