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
@arman-hpp
arman-hpp / DropAllDatabases.sql
Created September 2, 2016 14:42
Drop All Databases
DECLARE @name nvarchar(255)
DECLARE db CURSOR FOR
SELECT Name FROM sysdatabases
WHERE Name NOT IN ('master', 'tempdb', 'model', 'msdb')
OPEN db;
FETCH NEXT FROM db
@arman-hpp
arman-hpp / extended_properties.sql
Last active September 19, 2016 16:34
sys.extended_properties
select * from sys.extended_properties
EXEC sp_addextendedproperty
@name = N'Description',
@value = N'بانک اطلاعاتی بانک';
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N'گروه مرجع' , @level0type=N'SCHEMA',@level0name=N'dbo'
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@arman-hpp
arman-hpp / UsedCpuCores.sql
Created September 20, 2016 07:20
SqlServer used cpu cores
select cpu_count from sys.dm_os_sys_info
select scheduler_id,cpu_id, status, is_online from sys.dm_os_schedulers where status='VISIBLE ONLINE'
@arman-hpp
arman-hpp / KillDb.sql
Last active September 29, 2016 17:51
Kill Db
#1
SELECT d.name , convert (smallint, req_spid) As spid
FROM master.dbo.syslockinfo l, master.dbo.spt_values v, master.dbo.spt_values x, master.dbo.spt_values u, master.dbo.sysdatabases d
WHERE l.rsc_type = v.number and v.type = 'LR' and l.req_status = x.number and x.type = 'LS' and l.req_mode + 1 = u.number
and u.type = 'L' and l.rsc_dbid = d.dbid
and rsc_dbid = (SELECT TOP 1 dbid FROM master..sysdatabases WHERE name LIKE 'my_db')
SET @kill_process = 'KILL ' + @spid
EXEC master.dbo.sp_executesql @kill_process
@arman-hpp
arman-hpp / PrintAsPDF.cs
Created December 5, 2016 17:42
Print Stimulsoft Report As PDF With Telerik
var report = new StiReport();
report.Load((byte[])Resources.ResourceManager.GetObject("TestReport"));
var reportBusinessObjects = new List<ReportBusinessObject>
{
new ReportBusinessObject("", "TestReport", reportDto)
};
LoadBusinessObjects(report, reportBusinessObjects);
report.Compile();
report.Render(false);
@arman-hpp
arman-hpp / ChangeIPWithCMD.bat
Created December 10, 2016 04:01
Change IP With CMD
@echo off
set /p id="Enter Branch Code: "
@echo Please wait...
netsh interface ipv4 set address name="VirtualBox Host-Only Network" static 192.168.%id%.8 255.255.255.0 192.168.%id%.1
netsh interface ipv4 set dns name="VirtualBox Host-Only Network" static 8.8.8.8 PRIMARY
netsh interface ipv4 add dns name="VirtualBox Host-Only Network" 4.2.2.4 index=2
@echo Current branch changed to %id% Successfully.
pause
@arman-hpp
arman-hpp / ActiveDirectoryHelper.cs
Created December 28, 2016 07:03
Active Directory Helper
public static class ActiveDirectoryHelper
{
public static string GetSystemDomain()
{
try
{
return Domain.GetComputerDomain().ToString().ToLower();
}
catch (Exception ex)
{
@arman-hpp
arman-hpp / ExPow.cs
Last active April 17, 2017 08:01
Pow with overflow
public static int Sqr(double x, double y)
{
try
{
checked
{
return (int)Math.Pow(x, y);
}
}
catch (OverflowException)
@arman-hpp
arman-hpp / bytes.cs
Last active April 23, 2017 08:50
bytes
using System;
using System.Diagnostics;
using System.IO;
namespace TestBytes
{
class Program
{
static unsafe void Main(string[] args)
{
@arman-hpp
arman-hpp / Ebcdic.cs
Created May 1, 2017 03:41
AsciiToEbcdic
public static class Ebcdic
{
private static readonly char[] Ar1;
private static readonly char[] Ar2;
static Ebcdic()
{
Ar1 = new[]
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '¢', '.', '<', '(', '+', '|', '&', 'Q', 'R', 'S', 'T', 'U',