Skip to content

Instantly share code, notes, and snippets.

View nmanumr's full-sized avatar

Nauman Umer nmanumr

View GitHub Profile
@nmanumr
nmanumr / Scrapper.js
Last active March 24, 2019 10:47
COMSATS CourseWare Course Inbrowser Scrapper
/**
* Comsats CourseWare Inbrowser Scrapper
*
* @license
* Copyright (c) 2018 Nauman Umer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@nmanumr
nmanumr / wallpaper.sh
Created April 2, 2019 18:14
Downloads and set desktop background from bing
wget "https://www.bing.com$(curl -s "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1" |\
python3 -c "import sys, json; print(json.loads(sys.stdin.read())['images'][0]['url'])")" -O ./images/background.jpg -q
gsettings set org.gnome.desktop.background picture-uri ./images/background.jpg
@nmanumr
nmanumr / parser.js
Last active June 2, 2019 20:11
Parse single quiz MCQ
class McqParser {
getQuestionNode(doc) {
return doc.querySelector('.question_box>h3>p');
}
getOption(labelEl) {
return new McqChoice(
labelEl.innerHTML,
labelEl.title
@nmanumr
nmanumr / QuizDetailParser.js
Last active June 2, 2019 20:12
Parse wrong questions from quiz details
class TabularParser {
getNthCol(row, n) {
return row.querySelector(`td:nth-child(${n})`);
}
getNthColText(row, n) {
return this.getNthCol(row, n).innerText;
}
class McqParser {
getQuestionNode(doc) {
return doc.querySelector('.question_box>h3>p');
}
getOption(labelEl) {
return new McqChoice(
labelEl.innerHTML,
labelEl.title
var handlers = {
"GetAttemptedQuizDetails": detailPageHandler,
"PopulateSingleQuiz": McqPageHandler,
}
String.prototype.hashCode = function () {
var hash = 0, i, chr;
if (this.length === 0) return hash;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
@nmanumr
nmanumr / timetableParser.py
Last active September 8, 2019 15:19
Script to parse COMSATS Lahore Timetable from PDF
import argparse
import calendar
import re
import pdfplumber
class TableCell:
def __init__(self, rect, text):
self.left = rect[0]
@nmanumr
nmanumr / 4 letter words.java
Last active October 30, 2019 13:57
150 most used words
String[] words = {"that", "this", "with", "from", "your", "have", "more", "will", "home", "page", "free", "time", "they", "site", "what", "news", "only", "when", "here", "also", "help", "view", "been", "were", "some", "like", "than", "find", "date", "back", "list", "name", "just", "over", "year", "into", "next", "used", "work", "last", "most", "data", "make", "them", "post", "city", "such", "best", "then", "good", "well", "info", "high", "each", "very", "book", "read", "need", "many", "user", "said", "does", "mail", "full", "life", "know", "days", "part", "real", "item", "ebay", "must", "made", "line", "send", "type", "take", "area", "want", "long", "code", "show", "even", "much", "sign", "file", "link", "open", "case", "same", "both", "game", "care", "down", "size", "shop", "text", "rate", "form", "love", "john", "main", "call", "save", "york", "card", "jobs", "food", "sale", "teen", "room", "join", "west", "look", "left", "team", "week", "note", "live", "june", "plan", "cost", "july", "test", "come", "cart"
@nmanumr
nmanumr / threecubes.md
Last active August 20, 2020 14:57
solutions of x^3 + y^3 + z^3 = n where n < 100
n x y z
0 0 0 0
1 0 0 1
2 0 1 1
3 1 1 1
6 -1 -1 2
7 0 -1 2
8 0 0 2
9 0 1 2
import timeit
from terminaltables import SingleTable
def bubble_sort(arr):
for i in range(len(arr) - 1):
for j in range(0, len(arr) - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]