Skip to content

Instantly share code, notes, and snippets.

View utkarshmalik211's full-sized avatar
🎯
Focusing

Utkarsh Malik utkarshmalik211

🎯
Focusing
View GitHub Profile
@utkarshmalik211
utkarshmalik211 / stack.go
Created August 19, 2020 10:59 — forked from bemasher/stack.go
A simple LIFO stack backed by a linked list implemented with golang.
package main
import (
"fmt"
)
type Stack struct {
top *Element
size int
}
@utkarshmalik211
utkarshmalik211 / elasticScroll.py
Last active April 1, 2019 09:36
Minimal Python ElasticSearch scroll example WITHOUT client library
data = []
base_url="https://<elasticsearch-cluster-name>.us-west-2.es.amazonaws.com/"
payload = {
"size":10000,
"query":{
"match_all": {}
}
}
response = requests.post(base_url+"<index-name>/_search?scroll=1m", json=payload)
response = json.loads(response.content.decode())
@utkarshmalik211
utkarshmalik211 / fetchdata.py
Created February 1, 2019 12:11
Python script to extract all dynamoDB data to a .json file using boto3 .
import boto3
from boto3.dynamodb.conditions import Key, Key
import decimal
import json
AccessKey= "xxxxxxxxxxxxxxxxxxxxx" #aws access keys
SecretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
session = boto3.Session(
aws_access_key_id=AccessKey,
aws_secret_access_key=SecretKey,
@utkarshmalik211
utkarshmalik211 / i3-cheat-sheet.md
Created March 4, 2018 12:06 — forked from JeffPaine/i3-cheat-sheet.md
i3 Window Manager Cheat Sheet

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (alt by default)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3
@utkarshmalik211
utkarshmalik211 / main.cpp
Created November 4, 2017 05:54 — forked from nikotan/main.cpp
face detection sample code for OpenCV
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/ml.h>
void doMosaic(IplImage* in, int x, int y,
int width, int height, int size);
int main (int argc, char **argv)
{
int i, c;
@utkarshmalik211
utkarshmalik211 / as.py
Created February 8, 2016 13:47
Python script to scrape a given amazon page and list all the prices with item names (Basicaly for books)
from bs4 import BeautifulSoup
from urllib.request import urlopen
import re
try:
html=urlopen("http://www.amazon.in/b/ref=BizStrategy?_encoding=UTF8&node=1318070031&pf_rd_m=A1VBAL9TL5WCBF&pf_rd_s=merchandised-search-4&pf_rd_r=175CVN4B0C6BS94WK9BH&pf_rd_t=101&pf_rd_p=799588247&pf_rd_i=976389031").read()
except:
print("Connection Error")
else:
bsobj=BeautifulSoup(html,"html.parser")
for tag in bsobj.findAll('h2',{"class":"a-size-medium a-color-null s-inline s-access-title a-text-normal"}):
@utkarshmalik211
utkarshmalik211 / rps.py
Created December 22, 2015 07:47
Rock paper scissors game in python
"""Author : Utkarsh Malik
Monday , 21st Dec 2015 9:46PM
"""
from random import randint
print("Welcome to the rock paper scissor game\a\n")
repeat="Y"
y=1
while y==1:
print("For Player vs Cpu enter 1.\nFor Player1 vs Player2 enter 2\n")
try:
@utkarshmalik211
utkarshmalik211 / divisor_print.py
Created December 21, 2015 06:23
A python programme to print divisor(s) of a given no.
try:
val1=int(input("Enter a whole no : "))
except ValueError:
print("pls enter a whole integer ")
except KeyboardInterrupt:
print("As your wish")
else:
for e in range(1,100):
"""using 1 in range(1,100) to avoid ZeroDivisionError"""
@utkarshmalik211
utkarshmalik211 / list.py
Created December 21, 2015 06:09
A Python program that prints out all the elements of the list that are less than 5.
list1=[1,2,3,4,5,6,7,8,9,10,11,2,3,4,5,1,12,34,45,67,78,89,90]
list2=[]
list1.sort()
for e in list1 :
if e < 5:
list2.append(e)
print()
print(list2)
print()
lessthan=int(input("Enter a integer\n"))
@utkarshmalik211
utkarshmalik211 / even_check.py
Created December 21, 2015 05:53
Python programme to determine even or odd integer.
try:
val1=int(input("Enter a whole no : "))
except ValueError:
print("pls enter a whole integer ")
except KeyboardInterrupt:
print("As your wish")
else:
if val1 % 2 == 0 :
print(val1,"is even.")
else: