Skip to content

Instantly share code, notes, and snippets.

Avatar

Dawid Sibiński dsibinski

View GitHub Profile
View typescript_narrowing_in.ts
function GetManagedYearlySalary(person: Employee | Manager) {
if ('employees' in person) {
person.getYearlySalariesOfAllEmployees();
} else {
person.getYearlySalary();
}
}
View typescript_narrowing_1.ts
class Person {
name: string;
constructor(name: string) {
this.name = name;
}
}
class Employee extends Person {
salary: number;
View getnumberorlength_typeof.ts
function GetNumberOrLength(variable: string | number): number {
if (typeof variable === 'string') {
return variable.length;
} else {
return variable;
}
}
View getnumberorlength_cast.ts
function GetNumberOrLength(variable: string | number): number {
return (variable as string).length;
}
View getnumberorlength.ts
function GetNumberOrLength(variable: string | number): number {
return variable.length;
}
View RunningCypressFromCSharp.cs
public class FormTests: CypressTestsBase
{
[Test]
public void SubmitTests()
{
// some data initialization code here....
RunCypressTest("form/submit_spec.ts");
}
}
View CypressTestsBase.cs
public class CypressTestsBase
{
protected void RunCypressTest(string cypressSpecFilePath)
{
var process = new System.Diagnostics.Process();
var testAssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (string.IsNullOrEmpty(testAssemblyPath))
{
throw new Exception("Cannot find test assembly path!");
}
View custom_collection_minimal.cs
class MyObject
{
public int Value { get; set; }
}
class MyObjectEnumerator
{
public bool MoveNext()
{
throw new NotImplementedException();
View custom_IEnumerator_no_interface.cs
class MyObjectEnumerator
{
public bool MoveNext()
{
throw new NotImplementedException();
}
public void Reset()
{
throw new NotImplementedException();
View custom_IEnumerator.cs
class MyObjectEnumerator : IEnumerator<MyObject>
{
public bool MoveNext()
{
throw new NotImplementedException();
}
public void Reset()
{
throw new NotImplementedException();