Skip to content

Instantly share code, notes, and snippets.

View nmanumr's full-sized avatar

Nauman Umer nmanumr

View GitHub Profile
from django.db import transaction
from ordered_model.serializers import OrderedModelSerializer
from rest_framework import serializers
from rest_framework.serializers import ListSerializer
class ReplaceListSerializer(ListSerializer):
@transaction.atomic()
def update(self, instances, validated_data):
ins_mapping = {ins.id: ins for ins in instances}
@nmanumr
nmanumr / remove-merged.sh
Created January 13, 2022 16:51
remove all the merged branches
git --no-pager branch --merged main | xargs git branch -d
@nmanumr
nmanumr / cfg.h
Last active December 28, 2021 03:14
CFG
#include <iostream>
#include <string>
#include <list>
#include <unordered_map>
#include <set>
using namespace std;
#ifndef CC_CFG_H
#define CC_CFG_H
@nmanumr
nmanumr / eliminate_lr.java
Created November 12, 2021 17:45
CheatSheat
package practice;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;
public class eliminate_lr {
@nmanumr
nmanumr / rotate.js
Last active May 20, 2021 20:32
rotate youtube video
let conf = {
flipX: false,
flipY: true,
angle: 180,
};
function rotate(){
let theaterButton = $('.ytp-size-button.ytp-button');
if (theaterButton.title.includes("Theater")) {
setTimeout(rotate, 200);
@nmanumr
nmanumr / MonthSelector.tsx
Created May 15, 2021 19:08
Month Selector in React
import { Component, createRef, RefObject } from "react";
import c from 'classnames';
/*---------------------
* Component Types
*---------------------*/
interface State {
years: number[],
selected: string[],
@nmanumr
nmanumr / assignment01.py
Created October 9, 2020 15:29
NC assignment Bisection method, false position
import math
def r(x):
return str(round(x, 6))
def bisection_print(fn, xl, xu, last_xm=None, last_err=None, iter=1):
out_str = f"\\textbf{{Iteration {iter}}}\n\n"
out_str += "\n\\vspace{20pt}\\textbf{Step 1}\n"
out_str += f"$$ x_{{l}} = {r(xl)}, x_{{u}} = {r(xu)} $$\n"
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]
@nmanumr
nmanumr / feedback.js
Last active June 1, 2023 18:52
This script can automatically mark feedback for CUOnline Students Portal
let stars = () => 1 + Math.round(Math.random() * 4);
// uncomment this if you want fixed stars
// stars = () => 3;
// 'SUBJECT_CODE': [COURSE_STARS, FACULTY_STARS]
// for example `'CSE356': [1, 1]`
const specialSubjects = {
}
if (window.location.pathname == '/Feedback') {
@nmanumr
nmanumr / GPA.js
Created January 22, 2020 17:26
CUONLINE scripts
"use strict";
class GpaService {
constructor() {
this.s1Weight = 10;
this.s2Weight = 15;
this.finalWeight = 50;
this.quizWeight = 15;
this.assignWeight = 10;
}
calcTotal(entity) {