Skip to content

Instantly share code, notes, and snippets.

View azizkale's full-sized avatar
🇮🇹
</>

Aziz Kale azizkale

🇮🇹
</>
View GitHub Profile
@azizkale
azizkale / 01. with Factory Method.js
Last active August 9, 2021 17:53
how to send data to webservice in AngularJS
angCtlTable.factory("facYeniDonemAc", ["$http", function ($http) {
var fac = {};
fac.YeniDonemAc = function (kullaniciAdi, ay, yil, ctladi) {
return $http({
method: "POST",
url: "CTL_CRUDOperations.asmx/YeniDonemOlustur",
data: {
kullaniciAdi: kullaniciAdi,
ay: ay,
yil: yil,
@azizkale
azizkale / ToDataTable.cs
Created May 2, 2020 02:41
A Function for Convertiing From JSON to DataTable
public static DataTable ToDataTable<T>(IList<T> data)
{
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(T));
DataTable table = new DataTable();
for (int i = 0; i < props.Count; i++)
{
PropertyDescriptor prop = props[i];
table.Columns.Add(prop.Name, prop.PropertyType);
}
object[] values = new object[props.Count];
@azizkale
azizkale / 01-HowToDragMyDiv.js
Last active October 30, 2020 07:00
01-How To Drag My Div
var elment = document.getElementById("idOfMyDiv");
elment.addEventListener('mousedown', function (e) {
isDown = true;
offset = [
elment.offsetLeft - e.clientX,
elment.offsetTop - e.clientY
];
}, true);
document.addEventListener('mouseup', function () {
isDown = false;
@azizkale
azizkale / 04-Promise&serTimeoutFunction.ts
Last active October 30, 2020 06:59
04-Promise&serTimeoutFunction
isAuthenticated() {
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(this.loggedIn);
}, 700)
});
return promise;
}
import express from "express";
import data from "../data";
import bodyParser from "body-parser";
const postRouter = express.Router();
postRouter.use(bodyParser.json()); // to use body object in requests
postRouter.get("/", (req, res) => {
res.send(data);
});
const options = {
definition: {
openapi: "3.0.0",
info: {
title: "Library API",
version: "1.0.0",
description: "A simple Express Library API",
termsOfService: "http://example.com/terms/",
contact: {
name: "API Support",
/**
* @swagger
* components:
* schemas:
* Post:
* type: object
* required:
* - userId
* - title
* - body
/**
* @swagger
* tags:
* name: Posts
* description: posts of users
*/
/**
* @swagger
* /posts:
* get:
* summary: Returns all posts
* tags: [Posts]
* responses:
* 200:
* description: the list of the posts
* content:
/**
* @swagger
* /posts/{id}:
* get:
* summary: gets posts by id
* tags: [Posts]
* parameters:
* - in : path
* name: id
* description: id of post