Skip to content

Instantly share code, notes, and snippets.

View hackrio1's full-sized avatar

Hackrio hackrio1

  • Hackrio
  • Gurugram
View GitHub Profile
<html>
<head>
<style>
p {
color: #000000;
}
</style>
</head>
</html>
#include <stdio.h>
void bubble_sort(int a[], int n) {
int i = 0, j = 0, tmp;
for (i = 0; i < n; i++) { // loop n times - 1 per element
for (j = 0; j < n - i - 1; j++) { // last i elements are sorted already
if (a[j] > a[j + 1]) { // swop if order is broken
tmp = a[j];
a[j] = a[j + 1];
a[j + 1] = tmp;
{
_id: STUDENT_IDname: STUDENT_NAME,
data_of_birth: STUDENT_DATE_OF_BIRTH,
courses: [
{
code: COURSE_CODE,
instructor: COURSE_INSTRUCTOR,
},
{
code: COURSE_CODE,
gem 'bcrypt', '~> 3.1.7'
gem 'devise'
class User < ApplicationRecord
# Include default devise modules. Other Avaialavbles are:
# :confirmable, :lockable, :timeoutable, and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
class Article < ApplicationRecord
belongs_to :user
validates :title, :text, presence: true
end
class ApplicationController < ActionController::Base
before_action :authenticate_user
end
def set_user
@user = current_user
end
class ArticlesController < ApplicationController
before_action :set_user
before_action :set_article, only: [:show, :edit, :update, :destroy]
# GET /articles/1
# GET /articles.json
def index
@articles = @users.articles.all
end
Merge sort - Code
#include <stdio.h>
// function to sort the subsection a[i .. j] of the array a[]
void merge_sort(int i, int j, int a[], int aux[]) {
if (j <= i) {
return; // the subsection is empty or a single element
}
int mid = (i + j) / 2;