Skip to content

Instantly share code, notes, and snippets.

View sumit2312's full-sized avatar
:octocat:
Focusing

Sumit Kumar sumit2312

:octocat:
Focusing
View GitHub Profile
#!/usr/bin/env python
### Import required python libraries
import os
import time
import shutil
from boto.s3.connection import S3Connection
from boto.s3.key import Key
@sumit2312
sumit2312 / auth.py
Created January 3, 2022 12:55 — forked from ibeex/auth.py
Python LDAP (ActiveDirectory) authentication
import ldap
def check_credentials(username, password):
"""Verifies credentials for username and password.
Returns None on success or a string describing the error on failure
# Adapt to your needs
"""
LDAP_SERVER = 'ldap://xxx'
# fully qualified AD user name
LDAP_USERNAME = '%s@xxx.xx' % username

drf-cheat-sheet

A collection of anything from basics to advanced recommended methods and usages with Django REST Framework for creating browsable and awesome web API's. This could also serve as a quick reference guide.

Here is DRF's official documentation in case you need everything in detail.

Why Django REST Framework?

Summarized from the official docs:

  • Web browsable API
  • Serialization that supports ORM and non-ORM data sources.
import numpy as np
import cv2
def sp_noise(image, prob):
'''
Add salt and pepper noise to image
prob: Probability of the noise
'''
output = image.copy()
Task 1: Create a project jumphost instance
Navigation menu > Compute engine > VM Instance
Task 2: Create a Kubernetes service cluster
gcloud config set compute/zone us-east1-b
gcloud container clusters create nucleus-webserver1
// We can use stl container list as a double
// ended queue to store the cache keys, with
// the descending time of reference from front
// to back and a set container to check presence
// of a key. But to fetch the address of the key
// in the list using find(), it takes O(N) time.
// This can be optimized by storing a reference
// (iterator) to each key in a hash map.
#include <bits/stdc++.h>
using namespace std;
@sumit2312
sumit2312 / preSucc.java
Created June 26, 2020 17:44 — forked from anil477/preSucc.java
Inorder predecessor and successor for a given key in BST
// http://www.geeksforgeeks.org/inorder-predecessor-successor-given-key-bst/
// http://code.geeksforgeeks.org/NvtCcP
Input: root node, key
output: predecessor node, successor node
/*
1. If root is NULL
then return
2. if key is found then
a. If its left subtree is not null
Then predecessor will be the right most
@sumit2312
sumit2312 / webdev_online_resources.md
Created April 10, 2020 02:27 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@sumit2312
sumit2312 / add_intellij_launcer
Created September 14, 2019 06:40 — forked from rob-murray/add_intellij_launcer
Add Intellij launcher shortcut and icon for ubuntu
// create file:
sudo vim /usr/share/applications/intellij.desktop
// add the following
[Desktop Entry]
Version=13.0
Type=Application
Terminal=false
Icon[en_US]=/home/rob/.intellij-13/bin/idea.png
Name[en_US]=IntelliJ