Skip to content

Instantly share code, notes, and snippets.

View knowankit's full-sized avatar
🤓
Learning and building apps

Ankit Kumar knowankit

🤓
Learning and building apps
View GitHub Profile
from django.http import HttpResponse
from openpyxl import Workbook
from openpyxl.writer.excel import save_virtual_workbook
def home_page(request):
wb = Workbook()
ws = wb.active
ws.append(['First Name', 'Last Name'])
data = [{
@knowankit
knowankit / min-max-heap.js
Created February 6, 2022 06:14
Implementation of max and min heap in Javascript
/* Heaps */
// left child: i * 2
// right child: i * 2 + 1
// parent: i / 2
let MinHeap = function() {
let heap = [null];
@knowankit
knowankit / gihub-stargazers-count.ts
Created September 26, 2021 08:22
Get all the stargazers from your git hub
const getAllGithubStars = async () => {
const your_username = 'knowankit'
const URL = `https://api.github.com/users/${your_username}/repos`;
const response = await fetch(URL);
const data = await response.json();
let stars = 0;
for (let i = 0; i < data.length; i++) {
stars += data[i]['stargazers_count'];
# http://stackoverflow.com/questions/32122784/alias-script-to-delete-all-local-and-remote-git-branches-with-a-specific-prefix
git branch -D $(printf "%s\n" $(git branch) | grep 'feature/')
# Or this will work too to remove all remote branches:
# https://coderwall.com/p/eis0ba/remove-a-thousand-stale-remote-branches-on-git
git branch -r | awk -F/ '/\/feature/{print $2}' | xargs -I {} git push origin :{}
# Prune all origin branches
git remote prune origin
@knowankit
knowankit / commit-cheatsheet
Created November 24, 2019 04:25
A cheat sheet for a better commit messages
type feature -> title: Features, description: A new feature
type fix -> title: Bug Fixes, description: A bug fix
type docs -> title: Documentation, description: Documentation only changes
type style -> title: Styles, description: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
type refactor -> title: Code Refactoring, description: A code change that neither fixes a bug nor adds a feature
type perf -> title: Performance Improvements, description: A code change that improves performance
type test -> title: Tests, description: Adding missing tests or correcting existing tests
type build -> title: Builds, description: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
type ci -> title: Continuos Integration, description: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
type chore -> title: Chores, description: Other changes that don't modify src or test
@knowankit
knowankit / docker-help.md
Created August 16, 2019 11:47 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

alias ls='ls -F --color --show-control-chars'
alias ll='ls -l'
alias gits='git status '
alias gita='git add '
alias gitb='git branch '
alias gitc='git commit'
alias gitd='git diff'
alias gito='git checkout '
alias gitl='git log --graph --pretty=format:"%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset" --abbrev-commit --date=relative'
alias gitr='git remote update'