Skip to content

Instantly share code, notes, and snippets.

View jaydeepkarena's full-sized avatar
🚀
Fullstack Developer

Jaydeep Karena jaydeepkarena

🚀
Fullstack Developer
  • Navsari, Gujarat (India)
  • 19:40 (UTC +05:30)
  • X @JKarena7
View GitHub Profile
@jaydeepkarena
jaydeepkarena / C# Print Preview.md
Created May 8, 2019 04:38
C# - Show print preview of excel file

C# Print Preview using Microsoft.Office.Interop.Excel

Install Microsoft.Office.Interop.Excel using NuGet package

Install-Package Microsoft.Office.Interop.Excel

To show print preview use following code

@jaydeepkarena
jaydeepkarena / C# - Run async method as sync
Last active November 16, 2018 12:08
C# - Run async method as sync
public static class AsyncHelper
{
private static readonly TaskFactory _taskFactory = new
TaskFactory(CancellationToken.None,
TaskCreationOptions.None,
TaskContinuationOptions.None,
TaskScheduler.Default);
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
=> _taskFactory
@jaydeepkarena
jaydeepkarena / C# Extension Method Collection.txt
Created November 2, 2018 11:27
C# Extension Method Collection
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
@jaydeepkarena
jaydeepkarena / C# Extension Method - InvokeIfRequired.txt
Created November 2, 2018 11:25
C# Extension Method - InvokeIfRequired - use while updating control from different thread
public static void InvokeIfRequired<T>(this T control, Action<T> action) where T : Control
{
if (control.InvokeRequired)
{
control.Invoke(new Action(() => action(control)));
}
else
{
action(control);
}
@jaydeepkarena
jaydeepkarena / WrapText.ahk
Created October 30, 2018 04:45
AutoHotKey Wrap Text
/*
[script info]
version = 2.4
description = wrap selected text in %symbols%
author = davebrny
source = git.io/v1neW
*/
;Set tray icon
Menu, Tray, Icon, wrap.ico
@jaydeepkarena
jaydeepkarena / ToggleApps.ahk
Last active December 9, 2018 13:54
AutoHotKey Toggle Apps
; Add icon - just place icon file in same forlder
Menu, Tray, Icon, Toggle.ico
ToggleWinMinimize(TheWindowTitle)
{
SetTitleMatchMode,2
DetectHiddenWindows, Off
If WinActive(TheWindowTitle)
WinMinimize, %TheWindowTitle%
@jaydeepkarena
jaydeepkarena / Auto Correct.ahk
Last active December 8, 2018 06:47
AutoHotKey Auto Correct
;------------------------------------------------------------------------------
; Settings
;------------------------------------------------------------------------------
#NoEnv ; For security
#SingleInstance force
SetTitleMatchMode,2
;Set tray icon
;Menu, Tray, Icon, AutoCorrect.ico
@jaydeepkarena
jaydeepkarena / VS-SaveOnEnter.ahk
Last active October 30, 2018 04:46 — forked from MattBroyles/VS-SaveOnEnter.ahk
This is a simple AutoHotKey script that will auto-save Visual Studio on every press of the enter key.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
; Add icon - just place icon file in same forlder
Menu, Tray, Icon, fire.ico
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force