Skip to content

Instantly share code, notes, and snippets.

View margani's full-sized avatar
🌍
Happy!

Hossein Margani margani

🌍
Happy!
View GitHub Profile
@margani
margani / back-to-top.js
Last active February 10, 2017 09:54
Back to top button
// Back To Top
$('a.top').click(function(){ $('html, body').animate({scrollTop : 0},800); return false; });
//Create an anchor tag
<a class="top" href="#">Back to top</a>
@margani
margani / BackupAllDatabases.sql
Last active February 9, 2016 09:32
Simple SQL Server script for backup all databases in the current server
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
-- specify database backup directory
SET @path = 'C:\Backup\'
-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) + REPLACE(CONVERT(VARCHAR(20),GETDATE(),108),':','')

Keybase proof

I hereby claim:

  • I am margani on github.
  • I am margani (https://keybase.io/margani) on keybase.
  • I have a public key ASDlNdNCiswmDGHowyy0QX_SAj2Mpag0zYB166NkwD56XAo

To claim this, I am signing this object:

@margani
margani / XmlSerializationProgram.cs
Last active February 10, 2017 09:48
This class demonstrates methods for serializing and deserializing object to and from an xml string
class XmlSerializationProgram
{
static void Main(string[] args)
{
var person = new Person
{
firstName = "John",
lastName = "Doe",
dateOfBirth = new MyDate
{
@margani
margani / async-file-io.cs
Created February 10, 2017 09:50
This code is for io programming in sync and async modes
string StartDirectory = @"D:\temp\source";
string EndDirectory = @"D:\temp\destination";
private async void btnStartAsync_Click(object sender, EventArgs e)
{
foreach (string filename in Directory.EnumerateFiles(StartDirectory))
{
using (FileStream SourceStream = File.Open(filename, FileMode.Open))
{
var destFilePath = EndDirectory + filename.Substring(filename.LastIndexOf('\\'));
@margani
margani / JsonSerializationProgram.cs
Created February 10, 2017 09:51
This code demonstrates 4 methods of json serialization and deserialization
class JsonSerializationProgram
{
static void Main(string[] args)
{
var person = new Person
{
firstName = "John",
lastName = "Doe",
dateOfBirth = new MyDate
{
@margani
margani / customized-angular-app-generation.txt
Last active September 11, 2017 11:07
Creating new angular app with customized flags
ng new general-app --verbose --skip-tests --directory app --style less --routing
@margani
margani / EnableRemoteDesktopWindows.bat
Last active December 6, 2021 05:23
Enable or Disable Remote Desktop in Windows Firewall from Command Prompt #windows #rdp
# Windows Server 2008+ or Windows Vista+
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
publi class Project
{
public void DoScrum()
{
Developers.ForEach(dev =>
{
if(dev.IsMe)
{
Talking.Start(() => {
if(NothingFurtherToSay
@margani
margani / essentials.ps1
Last active December 1, 2023 14:00
Essential chocolatey packages #windows #choco #install #apps
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco upgrade -y googlechrome
choco upgrade -y notepadplusplus
choco upgrade -y 7zip
choco upgrade -y rdcman
choco upgrade -y adobereader
choco upgrade -y vlc
choco upgrade -y filezilla
choco upgrade -y sysinternals