Skip to content

Instantly share code, notes, and snippets.

View ketankr9's full-sized avatar

Utsav Krishnan ketankr9

  • Google
  • Indian Institute of Technology (BHU), Varanasi,India
View GitHub Profile
@ketankr9
ketankr9 / LeetcodeTimer.ketankr9.js
Last active May 19, 2020 06:50
Use this UserScript in any browser to see the time elapsed while solving a problem at leetcode.com . HowToInstall https://greasyfork.org/en/help/installing-user-scripts
// ==UserScript==
// @name Leetcode Timer
// @version 1.2
// @grant none
// @include *://*leetcode.com/problems/*
// @author ketankr9
// @namespace https://greasyfork.org/users/564674
// @description Start a timer whenever a user loads a problem at Leetcode.com
// ==/UserScript==
@ketankr9
ketankr9 / netusage.sh
Created December 24, 2019 14:28
output the value of any scripy in ubuntu unity panel
#!/bin/bash
echo $(($(cat /proc/net/dev | awk '{print $2}' | tail -n1) + $(cat /proc/net/dev | awk '{print $2}' | tail -n2 | head -n1)))
@ketankr9
ketankr9 / contest_bot.py
Last active July 23, 2019 07:00
Telegram bot which sends the schedule of programming contests held at various hosts.
TOKEN='****DECLARE YOUR TOKEN HERE****'
import time
import random
import telepot
from telepot.loop import MessageLoop
import requests
from datetime import datetime, timezone, date
import pytz
"""
@ketankr9
ketankr9 / iitbhulogin.service
Created June 7, 2019 05:08
hotspot login script at boot when the network is ready
#sudo systemctl edit --force --full iitlogin.service
#enter the below script and make sure ```sudo chmod u+x /usr/local/bin/forti```
----------------------------------------------------
[Unit]
Description=IIT Lan Login
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
@ketankr9
ketankr9 / scraper.py
Last active June 1, 2019 07:26 — forked from marcoqu/scraper.py
Script for scraping public instagram profile's timeline photos.
# pylint: skip-file
import time
import re
import md5
import requests
import json
INSTAGRAM_URL = "https://www.instagram.com"
HASHTAG_ENDPOINT = "/graphql/query/?query_hash={}&variables={}"
@ketankr9
ketankr9 / dovecot_dovecot.conf
Created February 1, 2019 10:05
mailserver postfix configuration and dovecot imap/pop3 setup
#$$$ cat /etc/dovecot/dovecot.conf
## Dovecot configuration file
# If you're in a hurry, see http://wiki2.dovecot.org/QuickConfiguration
# "doveconf -n" command gives a clean output of the changed settings. Use it
# instead of copy&pasting files when posting to the Dovecot mailing list.
# '#' character and everything after it is treated as comments. Extra spaces
# and tabs are ignored. If you want to use either of these explicitly, put the
#!/usr/bin/env bash
USED=$(ssh pratik@172.16.16.19 nvidia-smi | head -n9 | tail -n1 | awk {'print $9'})
echo "GPU:$USED"
echo "---"
echo "$USED/12195MiB"
#SCRIPT_STATE=$(ssh pratik@172.16.16.19 'pgrep -fa "python\sNeuralStyleTransfer"')
#if [ -z "$SCRIPT_STATE" ]; then
# echo "Exit"
#else
@ketankr9
ketankr9 / SimpleTCPClient.java
Created September 16, 2018 20:10
Java Socket implementation of Client.
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.List;
class SimpleTCPClient
{
private static Socket socket;
private static InputStream input;
* know your public ip: ~$ `curl ipecho.net/plain; echo`
~$ `curl icanhazip.com`
* get headers only
curl -sI http://167.99.226.14:8000/tshirt.jpg
* split files and download: `https://www.maketecheasier.com/split-download-large-file-curl/`
curl --range 0-100000 -o song.mp3.part1 http://url/song.mp3
curl --range 100001- -o song.mp3.part2 http://url/song.mp3 #till end, remaining
#join file
cat song.mp3.part? > song.mp3
import requests
from bs4 import BeautifulSoup as bs
import re
import csv
TAGS=["python"]
MAX_PAGES_PER_TAGS = 20 #int
FILENAME_PREFIX = "Dataset_"
# def writeToCSV(fileName):