Skip to content

Instantly share code, notes, and snippets.

View hridaydutta123's full-sized avatar
🎧
Alive and Awake

Hridoy Sankar Dutta hridaydutta123

🎧
Alive and Awake
View GitHub Profile
@hridaydutta123
hridaydutta123 / gist:a673db5e0145bc571d28c71035cb9405
Created June 3, 2020 07:38
Convert YouTube API duration to seconds
import re
def YTDurationToSeconds(duration):
match = re.match('PT(\d+H)?(\d+M)?(\d+S)?', duration).groups()
hours = _js_parseInt(match[0]) if match[0] else 0
minutes = _js_parseInt(match[1]) if match[1] else 0
seconds = _js_parseInt(match[2]) if match[2] else 0
return hours * 3600 + minutes * 60 + seconds
# js-like parseInt
@hridaydutta123
hridaydutta123 / perUserUsageChecker.py
Last active August 22, 2019 20:02
Code to check per-user data usage in the system
import sys
import os
# Get list of all users present in the system
allUsers = os.popen('cut -d: -f1 /etc/passwd').read().split('\n')[:-1]
for users in allUsers:
# Check if the home directory exists for the user
if os.path.exists('/home/' + str(users)):
# Print the current usage of the user
# Create-AP (Link : https://github.com/oblique/create_ap)
/usr/bin/DisarmBootScript
-------------------------
#!/bin/bash
/home/alarm/create_ap/create_ap -g 192.168.43.1 wlan0 eth0 DisarmHotspotDB
etc/systemd/system/DisarmBootScript.service
--------------------------------------------
[Unit]
Description=DisarmBootScript
@hridaydutta123
hridaydutta123 / herokuClearDB
Created July 7, 2017 07:24
Heroku Clear Database Commands
heroku pg:reset DATABASE_URL
heroku run python manage.py makemigrations
heroku run python manage.py migrate
@hridaydutta123
hridaydutta123 / macID
Created July 5, 2017 10:31
SHELL SCRIPT TO GENERATE HOTSPOT WITH MAC-ID
# Get the MAC id of the interface
MAC=`cat /sys/class/net/wlan0/address`
# Print the MAC ID without colon
echo "$MAC" | tr -d :
2017/6/15, 18:51:59, 1, 0, 0, 0, 0.21, 22.04, 43.97, 64.19, 26.62,
2017/6/15, 18:52:0, 2, 12, 28, 30, 0.21, 16.79, 43.97, 64.25, 26.59,
2017/6/15, 18:52:0, 3, 12, 28, 30, 0.21, 18.44, 43.97, 64.31, 26.62,
2017/6/15, 18:52:1, 4, 11, 28, 31, 0.21, 18.44, 43.97, 64.37, 26.59,
2017/6/15, 18:52:2, 5, 11, 28, 31, 0.21, 20.19, 43.97, 64.37, 26.66,
2017/6/15, 18:52:2, 6, 11, 28, 31, 0.21, 18.44, 43.97, 64.37, 26.59,
2017/6/15, 18:52:3, 7, 13, 28, 31, 0.21, 18.44, 43.97, 64.31, 26.62,
2017/6/15, 18:52:4, 8, 13, 28, 31, 0.21, 20.19, 43.97, 64.31, 26.59,
2017/6/15, 18:52:4, 9, 13, 28, 31, 0.21, 20.19, 43.97, 64.31, 26.62,
2017/6/15, 18:52:5, 10, 13, 28, 31, 0.21, 18.44, 43.75, 64.25, 26.62,