Skip to content

Instantly share code, notes, and snippets.

View sasan-salem's full-sized avatar
🏠
Working from home

Sasan Salem sasan-salem

🏠
Working from home
  • TOSAN (Banking and Payment Solutions Provider)
  • LinkedIn in/sasan-salem
View GitHub Profile
<?php
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($userAgent, 'Instagram')) {
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename= blablabla');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file);
}
else{
namespace DotNet.Controller
{
public class DummyBytesController : ApiController
{
[HttpGet]
public HttpResponseMessage Get()
{
HttpResponseMessage Response;
string UserAgent = HttpContext.Current.Request.UserAgent;
class Student
{
public string Name { get; set; }
public int Number { get; set; }
public int SerialNo { get; set; }
public int Grade { get; set; }
}
public override bool Equals(object obj)
{
if (obj is Student student)
{
if (student.SerialNo == SerialNo)
return true;
else
return false;
}
else
Student student1 = new Student()
{
Name = "Joe",
Grade = 3,
Number = 10,
SerialNo = 3213214
};
Student student2 = new Student()
{
bool result = false;
if (student1.GetHashCode() == student2.GetHashCode())
result = student1.Equals(student2);
Hashtable hashtable = new Hashtable();
hashtable.Add("MyFirstKey", 1);
hashtable.Add("MySecondKey", true);
if(hashtable.Contains("MySecondKey")) //it call Equals
Console.WriteLine("I found it");
class Student : IEquatable<Student>
{
public string Name { get; set; }
public int Number { get; set; }
public int SerialNo { get; set; }
public int Grade { get; set; }
public bool Equals(Student other)
{
if (other.SerialNo == SerialNo)
class Student : IEquatable<Student>
{
public string Name { get; set; }
public int Number { get; set; }
public int SerialNo { get; set; }
public int Grade { get; set; }
public bool Equals(Student other)
{
if (other.SerialNo == SerialNo)
List<Student> students = new List<Student>();
// Add some students to this List
var specificStudent = new Student() { SerialNo = 12, Number = 34, Grade = 3, Name = "Joe" };
bool exist1 = students.Contains(specificStudent, new NumberEqualityComparer());
bool exist2 = students.Contains(specificStudent, new SerialNoEqualityComparer());