Skip to content

Instantly share code, notes, and snippets.

View sr6033's full-sized avatar
๐Ÿ‹๏ธโ€โ™‚๏ธ
Building softwares that matter

Shubham Rath sr6033

๐Ÿ‹๏ธโ€โ™‚๏ธ
Building softwares that matter
View GitHub Profile
@sr6033
sr6033 / celery_commands.sh
Created June 22, 2020 13:40
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@sr6033
sr6033 / covid_alert.py
Last active April 5, 2020 15:58
Alerts you about new cases of COVID-19 inside India
"""
Running using CRONTAB:
1. crontab -e
2. * * * * * /usr/bin/python3 /home/{username}/covid_alert.py >> ~/cron.log 2>&1
3. Save & Exit
(You can also use any other scheduler to run the script)
"""
#!usr/bin/python3
import os
@sr6033
sr6033 / merge_sort.py
Last active February 18, 2020 11:11
MergeSort using python
def merge(arr, l, m, r):
n1 = m-l+1
n2 = r-m
L = []
R = []
for i in range(0, n1):
L.append(arr[l+i])
for i in range(0, n2):
R.append(arr[m+1+i])
i, j, k = 0, 0, l
@sr6033
sr6033 / largestNumber.cpp
Created December 12, 2019 07:34
Given a list of non negative integers, arrange them such that they form the largest number.
/* https://www.interviewbit.com/problems/largest-number/
Given a list of non negative integers, arrange them such that they form the largest number.
For example:
Given [3, 30, 34, 5, 9], the largest formed number is 9534330.
Note: The result may be very large, so you need to return a string instead of an integer.
*/
bool compare(string s1, string s2)
{
string s1s2 = s1 + s2;
@sr6033
sr6033 / merge_overlapping_intervals.cpp
Last active December 5, 2019 06:20
Merge Overlapping Intervals
/*
Given a collection of intervals, you have to merge all overlapping intervals.
For example: Given [2,6],[5,10],[15,18], return [2,10],[15,18].
Also, mark that the returned intervals list should in non-decreasing order.
--------------------------------------------------------------------------
struct Interval {
int start;
int end;
};
*/
@sr6033
sr6033 / heapSort.cpp
Created September 16, 2018 09:22
STL implementation of heapsort algorithm.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
char mat[n][m];
for(int i = 0; i < n; i++)
@sr6033
sr6033 / Makefile
Created September 6, 2018 13:12
Makefile to compile & execute OpenGL programs
# FILE specifies which files to compile as part of the project
FILE = main.cpp
# CC specifies which compiler we're using
CC = g++ -std=c++11
# COMPILER_FLAGS specifies the additional compilation options we're using
# -Wall will turn on all standard warnings
COMPILER_FLAGS = -Wall
@sr6033
sr6033 / triangle_rotate.cpp
Created September 6, 2018 13:10
OpenGL program using GLFW3 to rotate a triangle
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
static void error_callback(int error, const char* description)
{
fputs(description, stderr);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
@sr6033
sr6033 / singlyLinkedList.cpp
Last active August 15, 2018 15:57
Insertion & deletion in Singly Linked List
#include <bits/stdc++.h>
using namespace std;
typedef struct node{
int data;
struct node *next;
}node;
node* insertBegin(node *head, int n)
{
@sr6033
sr6033 / dfs_stl.cpp
Created August 12, 2018 06:13
Depth First Search using C++ STL
#include <bits/stdc++.h>
using namespace std;
vector< vector <int>> g;
vector<bool> v;
// Undirected graph
void addEdge(int a, int b)
{
g[a].push_back(b);