Skip to content

Instantly share code, notes, and snippets.

View faridprogrammer's full-sized avatar
😃
Working

Farid Bekran faridprogrammer

😃
Working
View GitHub Profile
@faridprogrammer
faridprogrammer / regex.md
Last active June 30, 2019 09:39
Useful RegEx

Collection of useful RegEx patterns for developers

1. Website with www or http:// or https://

(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}

2.Email Address

^\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{1,})+$

@faridprogrammer
faridprogrammer / abp-fa.xml
Created June 8, 2019 14:01
ABP Persian translation
<?xml version="1.0" encoding="utf-8" ?>
<localizationDictionary culture="en">
<texts>
<text name="HomePage" value="صفحه نخست" />
<text name="About" value="درباره" />
<text name="WelcomeMessage" value="به ایران استارتآپ خوش آمدید!" />
<text name="FormIsNotValidMessage" value="فرم معتبر نیست. لطفا خطاها را بررسی و رفع کنید." />
<text name="TenantNameCanNotBeEmpty" value="Tenant name can not be empty" />
<text name="InvalidUserNameOrPassword" value="نام کاربری یا رمز ورود نامعتبر است" />
<text name="ThereIsNoTenantDefinedWithName{0}" value="There is no tenant defined with name {0}" />
@faridprogrammer
faridprogrammer / FilesController.cs
Created June 6, 2019 22:17
Simple file upload for aspnet core and angular 6+- ABP (Upload component)
public class FilesController: BistoonControllerBase
{
[HttpPost, DisableRequestSizeLimit]
public IActionResult Upload()
{
try
{
var file = Request.Form.Files[0];
var folderName = Path.Combine("UploadedFiles");
var pathToSave = $"c:\\{folderName}";
public static class MimeTypeMap
{
private static readonly Lazy<IDictionary<string, string>> _mappings = new Lazy<IDictionary<string, string>>(BuildMappings);
private static IDictionary<string, string> BuildMappings()
{
var mappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
#region Big freaking list of mime types
@faridprogrammer
faridprogrammer / Classes.cs
Last active August 31, 2019 10:53
All IRAN provinces and cities SQL table insert script and entity classes for ABP
public class City: Entity<Guid>
{
public string Name { get; set; }
public Guid ProvinceId { get; set; }
public Province Province { get; set; }
public double Lat { get; set; }
public double Long { get; set; }
}
public class Province: Entity<Guid>
@faridprogrammer
faridprogrammer / iran_universities.sql
Last active May 21, 2019 08:04
All IRAN universities sql insert
-- Dolati = 1,
-- PayamNour = 2,
-- Elmi_Karbordi = 3,
-- GheirEntefaee = 4,
-- Azad = 5,
-- Fani = 6
insert into universities (name, type)
SELECT N'دانشکده فنی و حرفه‌ای پسران قزوین (شهیدبابایی)' as name ,6 as type
UNION ALL SELECT N'دانشکده فنی شهید بهشتی کرج' as name ,6 as type
@faridprogrammer
faridprogrammer / q-index-size
Created April 22, 2019 12:49
Get all indexes size of a database in sql server
SELECT
OBJECT_SCHEMA_NAME(i.OBJECT_ID) AS SchemaName,
OBJECT_NAME(i.OBJECT_ID) AS TableName,
i.name AS IndexName,
i.index_id AS IndexID,
8 * SUM(a.used_pages) AS 'Indexsize(KB)'
FROM sys.indexes AS i
JOIN sys.partitions AS p ON p.OBJECT_ID = i.OBJECT_ID AND p.index_id = i.index_id
JOIN sys.allocation_units AS a ON a.container_id = p.partition_id
GROUP BY i.OBJECT_ID,i.index_id,i.name
@faridprogrammer
faridprogrammer / two-way-binding.js
Created January 19, 2019 06:48 — forked from straker/two-way-binding.js
Simple and small two-way data binding between DOM and data
/**
* @param {object} scope - Object that all bound data will be attached to.
*/
function twoWayBind(scope) {
// a list of all bindings used in the DOM
// @example
// { 'person.name': [<input type="text" data-bind="person.name"/>] }
var bindings = {};
// each bindings old value to be compared for changes
@faridprogrammer
faridprogrammer / NetworkConnection.cs
Last active February 7, 2016 10:22
With net use commands of windows
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
namespace ConsoleApplication
{
public class NetworkConnection : IDisposable
{
private string _networkName;
@faridprogrammer
faridprogrammer / BarcodeController.cs
Last active June 22, 2017 08:24
Create barcode with Zen.Barcode.Core.Code128 int ASP.NET web api controller
using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Http;
using Zen.Barcode;
namespace WebApplication6.Controllers
{