Skip to content

Instantly share code, notes, and snippets.

View arman-hpp's full-sized avatar
😊
Focusing

Arman Hasanpour arman-hpp

😊
Focusing
View GitHub Profile
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
namespace TestMigrationHistory
{
class Program
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View("Home");
}
public ActionResult Login(string txtUsername, string txtPassword)
{
var x = Request.ToObj<User>();
public static class ExtendedPersianString
{
public static string FixPersianName(this string text)
{
if (string.IsNullOrEmpty(text)) return text;
return text.ApplyCorrectYeKe().ReplaceAlef().RemoveDiacritics().CleanUnderLines().RemovePunctuation().Trim().RemoveSpaces();
}
public static string ApplyCorrectYeKe(this string text)
{
SELECT * FROM TempOrgan
LEFT OUTER JOIN TOrgan ON TempOrgan.Organ Like '%' + TOrgan.OrganName + '%'
WHERE TOrgan.OrganName IS NULL
USE [Valieasr_336_17]
GO
WITH RowNumbers AS
(
select *,
RowNum = 10000000 + row_number() OVER ( order by Id )
from [Person].[Persons]
)
UPDATE RowNumbers
var binding = new BasicHttpBinding();
var address = new EndpointAddress("http://localhost:65182/TestService.svc");
var factory = new ChannelFactory<ITestService>(binding, address);
var channel = factory.CreateChannel();
Console.WriteLine("Result: {0}", channel.DoWork(2, 3));
Console.ReadKey();
@arman-hpp
arman-hpp / gist:a414c3d66ed17b9aa55c
Created March 5, 2016 15:35
SqlServer Context Info Business User
//http://jasondentler.com/blog/2010/01/exploiting-context_info-for-fun-and-audit/
DECLARE @Ctx varbinary(128)
SELECT @Ctx = CONVERT(varbinary(128), 'Arman')
SET CONTEXT_INFO @Ctx
DECLARE @CtxData varchar(128)
SELECT @CtxData = CONVERT(VarChar(128), CONTEXT_INFO())
PRINT @CtxData
@arman-hpp
arman-hpp / CopyFrom.cs
Last active May 8, 2016 09:00
CopyFrom
public static class Ex
{
public static T CopyFrom<T>(this T objTarget, T objSource)
{
var typeSource = objSource.GetType();
var propertyInfo = typeSource.GetProperties();
foreach (var property in propertyInfo.Where(property => property.CanWrite))
{
if (property.PropertyType.IsPrimitive())
@arman-hpp
arman-hpp / DbContextExtensions.cs
Last active May 10, 2016 15:27
DbContextExtensions
public static class DbContextExtensions
{
public static string GetMigrationHistoryModel(this DbContext dbContext)
{
var modelBase64 = dbContext.Database.SqlQuery<string>(@"
DECLARE @binaryContent VARBINARY(MAX);
SELECT @binaryContent = Model FROM [__MigrationHistory];
SELECT CAST('' AS XML).value( 'xs:base64Binary(sql:variable(''@binaryContent''))', 'varchar(max)' ) AS base64Content;"
).FirstOrDefault();
@arman-hpp
arman-hpp / GhamariConvertor.cs
Created May 14, 2016 13:34
Miladi and Shamsi to Ghamari
public static class GhamariDate
{
private const decimal GREGORIAN_EPOCH = 1721425.5M;
private const decimal ISLAMIC_EPOCH = 1948439.5M;
public static string MiladiToGhamari(DateTime date)
{
var result = j_gh(date.Year, date.Month, date.Day);
return string.Format("{0}/{1}/{2}", result[0], result[1], result[2]);
}