Skip to content

Instantly share code, notes, and snippets.

@Mukundan314
Mukundan314 / custom-test.py
Created June 25, 2020 12:02
Tool to do custom tests on codeforces form cli
import argparse
import getpass
import pathlib
import sys
import time
import lxml.html
import requests
LANG_TO_ID = {
7760271406486818269530232833213886664232322405923376103150619226903215930614069531943489553238330332385800231950890047033440942119828335089534461575588743649189679666551254647725845465104616027482769081922732732396247083767521718123833193071062059470897781028461513719299898681118688416927278569657347426759698333740863013275725181399039295240867535897511016330381995952286224898977476794934777588622737237462556750901162963406793824520542616769323712193802126066318528132663283452332581822161262798206752262793825532048353317745360788194195100129025353789079430770802223904770027123239826800547510706333124064018424941062645591356335709328739507098468251865084648997734103578487702314212070231873054292195983109500375466193591164922665755209918440066710594444899354146614740178809647842125684176862138118817367066494869393494274783880447339843717996563382163956150672906821404597658562589543801065495963894323168124620435108355068741788022153704876207355787873171237620360350015436680204756119712795879795153546119920216229
// Code used to find the proof
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <vector>
import math
import scipy.misc
from manimlib.imports import *
class NewtonRaphson(GraphScene):
CONFIG = {
"func": lambda x: ((x - 2)**2) * math.sin(2 * x) / 3 + 10,
"initial_guess": 5,
"num_iters": 7,

Creating a systemd service

Format of systemd service files

service files for systemd are writtern in a format similar to toml and ini

Sections in the service file

  • [Unit] and [Install] - carries generic information about the unit that is not dependent on the type of unit
  • [Service] - carries information about the process the service files executes
import pathlib
import sys
import glob
import os
import io
from PIL import Image
def main():
#!/bin/bash
all_devices=($(ls /sys/block/))
usb_devices=()
for device in "${all_devices[@]}"
do
if readlink -f "/sys/block/$device/device" | grep -q "usb"
then
usb_devices+=($device)
import string
substitutions = {
'a': ['@'],
'b': ['8'],
'c': ['('],
'd': ['6'],
'e': ['3'],
'f': ['#'],
'g': ['9'],
import argparse
import os
import sys
import geopandas
import matplotlib.pyplot as plt
def main(argv):
parser = argparse.ArgumentParser()

Why is numpy's matrix multiplication faster than matrix multiplication implemented in plain python?

numpy's matrix multiplication are written in c/c++ which means they can be pre-compiled to give better performance

Why can't we compile python code?

compiling python code is posible if someone writes a compiler for it, through this is very hard and no one has done it yet, but there are compilers which compile some parts of the python code

What is numba?