Skip to content

Instantly share code, notes, and snippets.

View SafaElmali's full-sized avatar
🎮
Focusing

T. Safa Elmalı SafaElmali

🎮
Focusing
View GitHub Profile
@SafaElmali
SafaElmali / TodoItem.cs
Created May 1, 2019 14:14
TodoItem Model
namespace TodoProject.Models {
public class TodoItem {
public long Id { get; set; }
public string Item { get; set; }
public bool IsActive { get; set; }
}
}
@SafaElmali
SafaElmali / TodoContext.cs
Created May 1, 2019 14:20
Database Context
using Microsoft.EntityFrameworkCore;
namespace TodoProject.Models{
public class TodoContext : DbContext {
public TodoContext(DbContextOptions<TodoContext> options) : base(options)
{
}
@SafaElmali
SafaElmali / Product.cs
Created May 2, 2019 17:01
Product Entity class
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EFCore.Models {
[Table ("PRODUCT")]
public class Product {
[Key]
[Column ("ID")]
@SafaElmali
SafaElmali / EFContext.cs
Last active May 3, 2019 21:44
Context file
using Microsoft.EntityFrameworkCore;
namespace EFCore.Models {
public class EFContext : DbContext {
private const string connectionString = "Server=.\\;Database=EFCore;Trusted_Connection=True;";
protected override void OnConfiguring (DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseSqlServer (connectionString);
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace EFCore.Migrations
{
public partial class FirstMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
@SafaElmali
SafaElmali / ArraySort.js
Last active May 10, 2019 20:12
Sorting Algorithm
//Sorting Algorithm
function sortArray(arr) {
let temp;
for (let i = 0; i < arr.length; i++) {
if (arr[i] > arr[i + 1]) {
temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
console.log(arr);
return sortArray(arr);
@SafaElmali
SafaElmali / TryCatch.js
Last active December 22, 2020 05:35
Hackerrank - 10 Days of Javascript - Day 3: Try, Catch, and Finally
function reverseString(s) {
try {
let SplitString = s.split("");
let ReversedArray = [];
for (let i = SplitString.length - 1, j = 0; i > -1; i-- , j++) {
ReversedArray[j] = SplitString[i];
}
console.log(ReversedArray.join("")); //4321
} catch (ex) {
console.log(ex.message)
function Factorial(n) {
if (n === 1) {
return n;
} else {
return n * Factorial(n - 1);
}
}
Factorial(3); //6
@SafaElmali
SafaElmali / constantcomplexity.js
Created July 13, 2019 12:56
Constant-Time Algorithm - O(1)
let getLastItem = items => {
console.log(items[items.length - 1]);
}
getLastItem([10, 2, 20, 11000, 32, 123, 241312, 32142, 32131]);
@SafaElmali
SafaElmali / linearcomplexity.js
Last active July 13, 2019 13:10
O(n): Linear Complexity
let displayArrayElements = array => {
array.forEach((value) => {
console.log(value);
});
}
let numArray = [21,23,12321,312,312,312,3,14,12,4,32,53,5,234,1,32,13,12,41,321,4,124];
displayArrayElements(numArray);