Skip to content

Instantly share code, notes, and snippets.

Avatar

Shahriar Hossain shahriarhossain

View GitHub Profile
@shahriarhossain
shahriarhossain / Desktime.Hack.ps1
Created Aug 23, 2020 — forked from nayan2/Desktime.Hack.ps1
This is a script that will help you to hack your desktime activity by moving mouse
View Desktime.Hack.ps1
# Clear the host
Clear-Host
# Write/Log the starting date and time
Write-Host "Desktime Hack Started At" (Get-Date -Format G)
# Load assembly to manipulate mouse funationality
Add-Type -AssemblyName System.Windows.Forms
# Load Win 32 dll method for minimize and maximize window
@shahriarhossain
shahriarhossain / TupleCreation_5
Created Aug 30, 2016
Specifying element names directly in tuple literals
View TupleCreation_5
public (string, string, int) CoolWay_UserInfo(param1, param2, param3.....)
{
string firstName = "Shahriar";
string lastName = "Hossain";
int yearsOfExpertise = 4;
return (fName: firstName, lName: lastName, experience: yearsOfExpertise);
}
@shahriarhossain
shahriarhossain / TupleCreation_4
Last active Aug 30, 2016
You can optionally send name that make more sense to you
View TupleCreation_4
public (string fName, string lName, int experience) CoolWay_UserInfo()
{
string firstName = "Shahriar";
string lastName = "Hossain";
int yearsOfExpertise = 4;
return (firstName, lastName, yearsOfExpertise);
}
@shahriarhossain
shahriarhossain / TupleCreation_3
Last active Aug 30, 2016
Tuple gets simplier with the release of C# 7.0
View TupleCreation_3
public (string, string, int) CoolWay_UserInfo()
{
string firstName = "Shahriar";
string lastName = "Hossain";
int yearsOfExpertise = 4;
return (firstName, lastName, yearsOfExpertise);
}
View TupleCreation_2
public static Tuple<int, int, int, int, int, int, int, Tuple<Tuple<int, int>>> OldWay_TupleCreation()
{
Tuple<int, int> twoTuple = new Tuple<int, int>(9, 10);
var tempTumple = Tuple.Create(1, 2, 3, 4, 5, 6, 7, twoTuple);
return tempTumple;
}
View TupleUsages_1
public static void Main(string[] args)
{
var x = OldWay_UserInfo();
Console.WriteLine("{0} {1} {2}", x.Item1, x.Item2, x.Item3);
}
@shahriarhossain
shahriarhossain / TupleCreation_1
Last active Aug 30, 2016
Creating Tuple in C#
View TupleCreation_1
public static Tuple<string, string, int> OldWay_UserInfo()
{
string firstName = "Shahriar";
string lastName = "Hossain";
int yearsOfExpertise = 4;
Tuple<string, string, int> userInfo = new Tuple<string, string, int>(firstName, lastName, yearsOfExpertise);
//or
//var userInfo = Tuple.Create(firstName, lastName, yearsOfExpertise);
return userInfo;
}
View Getting NameResolutionFailure error
private const string BaseUrl = "http://intilaqemployees.azurewebsites.net/api/employeesapi";
public async Task<List<Employee>> GetEmployeesAsync()
{
var httpClient = new HttpClient();
try
{
var jsonResponse = await httpClient.GetStringAsync(BaseUrl).ConfigureAwait(false);
//The following line never gets executed
View JsonDateSerialization
var settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
Converters = new List<JsonConverter>
{
new IsoDateTimeConverter()
{
DateTimeFormat= "yyyy-MM-dd HH:mm:ss"
}
View Webjob_SDK_example_BlobTrigger_01
public static void ProcessText([BlobTrigger(@"input-dir/{name}.txt")] TextReader content,
string name,
[Blob(@"output-dir/{name}")] TextWriter contentOutput)
{
Console.WriteLine(String.Format("Reading Content from : {0}", name));
var temp = String.Format("Contents : {0}", content.ReadToEnd());
contentOutput.WriteLine(temp);
}
public static void CopyBlobToBlob([BlobTrigger(@"input-dir/{name}.jpeg")] Stream content,
You can’t perform that action at this time.