Skip to content

Instantly share code, notes, and snippets.

View codersguild's full-sized avatar
🏭
Code, Test, Build, Ship, Sleep

Sumit Lahiri codersguild

🏭
Code, Test, Build, Ship, Sleep
View GitHub Profile
@codersguild
codersguild / README.md
Last active February 16, 2022 09:41
Delete Slack file from the terminal.

Slack Files Deleter

This is a script to delete your slack app files in bulk on the fly using the latest slack API. Modified from here

  • This script does not store any username or password.
  • Needs xoxb or xoxp user token. Create a new app at https://api.slack.com/apps, register for user and bot tokens.
  • Please use at your own risk, it delete all files for the given "user" by "id" so file filtering may be possible.
  • user id the user_id, you can get it from slack under your profile from the slack app.
@codersguild
codersguild / emailsettings.md
Last active March 27, 2022 14:10
Email Settings

Settings

IIT Kanpur Email endpoints.

qasid.iitk.ac.in : 993
mmtp.iitk.ac.in : 465
@codersguild
codersguild / README.md
Last active March 3, 2021 15:25
For Code Review : GitHub reset, squash and PR !!

👨‍💻 For Code Review : GitHub reset, squash and PR 👨‍💻

Introduction

We often want to squash and combine the last N commits into one single commit before sending a PR for reviewing. This practice is quite prevelant in Google, Microsoft, Netflix and many other companies that have a strong culture of code reviewing.

How to do it?

Well, we first statrt by soft resetting the last N commits without lossing the file changes.

@codersguild
codersguild / README.md
Last active October 12, 2020 13:49
Examples for en.cppreference.com
@codersguild
codersguild / Kruskals_algo.md
Last active October 9, 2020 13:25
Kruskal's Algorithm in C++

TapChief Article : MST using Kruskal

Algorithm to find a minimum spanning tree in using Kruskal's Algorithm.

Code Listing :

  • Implement an efficient DS for storing a graph in C++.
  • Implement BFS, DFS and other traversals
  • Implement Kruskals Algo using this custom graph-ds.
@codersguild
codersguild / CONCURRENT_CPP.md
Last active October 3, 2020 08:11
Simple concurrent programming in C++

TapChief Article : Concurrent Programming in C++

Modern C++ is more awesome than you think. In OS related process communication and IPC in general there is a paradigm that helps in synchronization using a sleep/wake lock variable. The following code uses a mutex object along with sleep/wake variable. In C++, there is something called RAII (Resource Acquisition is Initialization), the mutex object is passed to unique lock locker like that in RAII way.

Let's Code

  • Create multiple producer threads that place consumable object up into a queue.
  • Create multiple consumer threads that can consume that object in an ordered manner.
@codersguild
codersguild / THREADING_FUTURE.md
Last active October 3, 2020 08:11
Simple Threading Example in C++.

TapChief Article : Promise and Futures in C++

Promise and future have been features of C++ since C++11.

Objective : Using a promise and passing a future to a thread, Set the promise later. Use the promise returned value in thread execution.

We can continue with thread execution in the meantime if the value is not required at that instant.
We can use the value of a promise later when it's available. Exceptions of the type broken_promise occurs if the promise is not returned to the executing thread.

@codersguild
codersguild / z3_cdcl.py
Created August 21, 2020 15:47
How SAT/SMT solvers work? CDCL and learning conflicts. Using z3 example in python
# -*- coding: utf-8 -*-
from z3 import *
S = Solver()
a, b, c = Ints('a b c')
"""
A predicate which tells if a given set of values assigned to a, b, c
satisfy the given constraints.
"""
@codersguild
codersguild / Tail_Recursion.md
Last active September 24, 2020 03:52
Understanding Tail Recursion

Tail Recursion

Let the function do no work after it returns on finishing a subsequent recursive call. By that we mean, the function does not compute anything usefull after a recursive call ends. The recursion is used in it's true form to just keep track of how many times to call and not be a part of successive computations.

// Non Tail Recursive factorial
unsigned long long int factorial (unsigned int x) {
	return x > 0 ? x * factorial(x - 1) : 1;