This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
p { | |
color: #000000; | |
} | |
</style> | |
</head> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
_id: STUDENT_IDname: STUDENT_NAME, | |
data_of_birth: STUDENT_DATE_OF_BIRTH, | |
courses: [ | |
{ | |
code: COURSE_CODE, | |
instructor: COURSE_INSTRUCTOR, | |
}, | |
{ | |
code: COURSE_CODE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'bcrypt', '~> 3.1.7' | |
gem 'devise' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ApplicationRecord | |
# Include default devise modules. Other Avaialavbles are: | |
# :confirmable, :lockable, :timeoutable, and :omniauthable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article < ApplicationRecord | |
belongs_to :user | |
validates :title, :text, presence: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_action :authenticate_user | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_user | |
@user = current_user | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
OlderNewer