Skip to content

Instantly share code, notes, and snippets.

View mraarif's full-sized avatar
🐳

Aarif mraarif

🐳
View GitHub Profile

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@mraarif
mraarif / tell_if_array_can_be_divided_into_three_equal_sums.py
Created June 24, 2019 11:03
This gist solves the problem of determining whether if given array can be divided into three non empty partitions and sum of those partitions is same.
def check_if_passes(input_array):
is_divisible = sum(input_array) % 3 == 0
if not is_divisible:
return is_divisible
chunk = sum(input_array) / 3
entries = []
addition = 0
for item in input_array:
addition = item + addition
if addition == chunk:
@mraarif
mraarif / python_multipart_fileupload.py
Created October 26, 2018 12:15
python How to upload file, multipart Post request
import requests
def post_multipart():
try:
user = {'email': 'testuser@example.com', 'first_name': 'test user 1','password': 'samplepassword'}
image = {'image': open('path/to/file', 'rb')}
requests.post('/api/url', files=image, data=user)
except Exception as ex:
print('user creation failed')
@mraarif
mraarif / DateTimeComparisonExtensions.cs
Created May 8, 2018 10:25
How to compare DateTime in C# Ignoring milliseconds
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Utils
{
public static class DateTimeComparisonExtensions
{
@mraarif
mraarif / DateTimeExtenions.cs
Created May 7, 2018 14:25
Check DateTime in C#, if it's happening now or in one minute (ignoring miliseconds)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Utils
{
public static class DateTimeExtensions
{
@mraarif
mraarif / FileUploadHelper.cs
Last active February 25, 2018 19:05
C# How to automatically rename uploaded file if there's already a file with same name
using System.IO;
using System.Linq;
using System.Web;
namespace static class FileUploadHelper
{
//customize the file size limit accordingly
private const double MaximumFileSize=10*1024*1024;
public static string UploadFile(HttpPostedFile file)