Skip to content

Instantly share code, notes, and snippets.

View tayyebi's full-sized avatar
📿
Grateful

MohammadReza Tayyebi tayyebi

📿
Grateful
View GitHub Profile
@tayyebi
tayyebi / G2J.sql
Created July 4, 2017 04:55
Convert Gregorian to Shamsi (Julian)
/*
CopyRight
http://rastan.parsiblog.com/Posts/381/%D8%AA%D8%A8%D8%AF%D9%8A%D9%84+%D8%B3%D8%A7%D8%AF%D9%87+%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE+%D9%85%D9%8A%D9%84%D8%A7%D8%AF%D9%8A+%D8%A8%D9%87+%D8%B4%D9%85%D8%B3%D9%8A+%D8%AF%D8%B1+SQL+Server/
*/
CREATE FUNCTION dbo.[G2J] ( @intDate DATETIME, @Format NVARCHAR(max))
@tayyebi
tayyebi / GenerateRandom.sql
Created June 8, 2017 11:42
Generate Random 10 Char String SQL
select SUBSTRING(Replace(CONVERT(varchar(255), NEWID()), '-', ''), 0, 10)
declare @TableName sysname = 'Charity'
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
@tayyebi
tayyebi / telegram.sh
Created April 4, 2017 18:18
Set permission to user in order to own everything in a directory
#!/bin/bash
sudo chown $(id -u):$(id -g) -R /home/rexa/.local/share/TelegramDesktop/*
## You could try to open the terminal,
## then
> sudo gedit /etc/default/grub
## and in the line that says:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
## change it for:
@tayyebi
tayyebi / HomeController.cs
Last active March 30, 2017 18:48
count down with matrix
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@tayyebi
tayyebi / sqlInstances.txt
Created March 25, 2017 13:46
Get SQL instances
Just open cmd as admin and:
for localdb:
sqllocaldb i
for express and other instances:
OSQL -L
@tayyebi
tayyebi / tsqlexec.snippet
Created March 25, 2017 12:47
SQL Execute and SQL Read commands snippet for 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>
<Title>Transact SQL Execute</Title>
<Author>MohammadReza Tayyebi github.com/tayyebi</Author>
<Description>Creates SQL Execute</Description>
<Shortcut>tsqlexec</Shortcut>
</Header>
@tayyebi
tayyebi / fiddler-post.txt
Created March 23, 2017 14:32
send a post request form fiddler and receive it from asp.net mvc api
in fiddler composer:
Content-Type: application/x-www-form-urlencoded
and parameters in mvc api must be same as:
public void Post([FromBody]string password)
@tayyebi
tayyebi / GordibuteAttribute.cs
Created March 23, 2017 08:03
Global authentication attribute for MVC
using System;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
namespace Gordafarid.Controllers
{
internal class GordibuteAttribute : ActionFilterAttribute, IActionFilter