Skip to content

Instantly share code, notes, and snippets.

View Saima-Chaity's full-sized avatar

Saima-Chaity

View GitHub Profile
class Solution:
def maxLength(self, ribbons: List[int], k: int) -> int:
low = 1
high = max(ribbons)
result = 0
while low <= high:
mid = (low+high)//2
current = 0
for ribbon in ribbons:
class Solution:
def validWordAbbreviation(self, word: str, abbr: str) -> bool:
i = 0
j = 0
number = 0
while i < len(word) and j < len(abbr):
if abbr[j].isdigit():
number = 10 * number + int(abbr[j])
if number <= 0:
break
class BST:
def __init__(self, start, end):
self.start = start
self.end = end
self.left = None
self.right = None
class Solution:
def __init__(self):
self.root = None
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
if len(intervals) == 0:
return []
if len(intervals) == 1:
return intervals
intervals.sort()
result = [intervals[0]]
import Sound from 'react-native-sound';
Sound.setCategory('Playback');
const sound = new Sound('http://example.com', (error) => {
if (error) {
// do something
}
// set volume
def check_time(delay, task):
next_time = time.time() + delay
while True:
time.sleep(max(0, next_time - time.time()))
try:
task()
except Exception:
traceback.print_exc()
# skip tasks if we are behind schedule:
next_time += (time.time() - next_time) // delay * delay + delay
def addTodo(request):
receiver_email = ""
notification_time = "not available"
if request.POST['email_notification']:
receiver_email = request.POST['email_notification']
if request.POST['todo_notification_time']:
notification_time = request.POST['todo_notification_time']
sendEmail(request, receiver_email, notification_time)
def index(request):
todo_items = Todo.objects.order_by('-due_date')[:10]
category_items = Category.objects.all()
notification_time = NotificationTime.objects.all()
current_date_time = datetime.now()
dt_string = current_date_time.strftime("%m/%d/%Y %I:%M %p")
splited_dt_string = dt_string.split(" ")
context = {
'todo_items': todo_items,
from django.urls import path
from . import views
app_name = 'todos'
urlpatterns = [
path('', views.index, name='index'),
path('addTodo/', views.addTodo, name='addTodo'),
path('addCategory/', views.addCategory, name='addCategory'),
path('<int:todo_id>/edit/', views.edit, name='edit'),
path('<int:todo_id>/update/', views.update, name='update'),
from django.db import models
import datetime
class Category(models.Model):
category_name = models.CharField(max_length=100)
todo_count = models.IntegerField(default=0)
def __str__(self):
return self.category_name