Skip to content

Instantly share code, notes, and snippets.

View Mds92's full-sized avatar

Mohammad Dayyan Mds92

  • Iran
  • 23:27 (UTC +03:30)
View GitHub Profile
@Mds92
Mds92 / SqlTableToCSharpClass.sql
Last active April 10, 2022 19:24
Sql Server Table To C# Class Includes Comment
USE [YourDataBaseName]
GO
/****** Object: StoredProcedure [dbo].[SqlTableToCSharpClass] Script Date: 4/10/2022 11:51:07 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
{
"name": "@ckeditor/ckeditor5-build-classic-mds",
"version": "0.1.0",
"description": "The classic editor build of CKEditor 5 – the best browser-based rich text editor.",
"keywords": [
"ckeditor5-build",
"ckeditor",
"ckeditor5",
"ckeditor 5",
"wysiwyg",
@Mds92
Mds92 / typescript-pagination.ts
Last active May 2, 2019 18:34
Pagination Algorithm in Typescript
static getPagination(currentPage: number, totalPages: number): string[] {
const delta = 2,
left = currentPage - delta,
right = currentPage + delta + 1,
range: number[] = [],
rangeString: string[] = [];
let tmp = 0;
for (let i = 1; i <= totalPages; i++) {
if (i == 1 || i == totalPages || i >= left && i < right) {
@Mds92
Mds92 / groupBy.ts
Last active March 1, 2019 14:25
GroupBy an array in TypeScript
export interface GroupByModel {
key: any;
value: any[];
}
export class Utility {
static groupBy(xs: any, f: Function): any[] {
const groupByObjects = xs.reduce((r: any, v: any, i: any, a: any, k = f(v)) => ((r[k] || (r[k] = [])).push(v), r), {});
const groupByModels: GroupByModel[] = [];
for (const obj in groupByObjects) {
@Mds92
Mds92 / Method.snippet
Last active April 13, 2018 03:31
Code snippet for methods in Visual Studio C#
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>method</Title>
<Author>Mohammad Dayyan</Author>
<Description>Code snippet for method</Description>
@Mds92
Mds92 / object-to-formdata.ts
Last active July 15, 2020 09:21
TypeScript Object to FormData, with support for nested objects, arrays and File objects.
static convertModelToFormData(model: any, form: FormData = null, namespace = ''): FormData {
let formData = form || new FormData();
for (let propertyName in model) {
if (!model.hasOwnProperty(propertyName) || model[propertyName] == undefined) continue;
let formKey = namespace ? `${namespace}[${propertyName}]` : propertyName;
if (model[propertyName] instanceof Date) {
formData.append(formKey, this.dateTimeToString(model[propertyName]));
}
else if (model[propertyName] instanceof Array) {
model[propertyName].forEach((element, index) => {