Skip to content

Instantly share code, notes, and snippets.

View lablnet's full-sized avatar
🏠
Working from home

Muhammad Umer Farooq lablnet

🏠
Working from home
View GitHub Profile
@lablnet
lablnet / waste_mem.cpp
Created July 30, 2020 07:26
Simple C++ program to waste memory
#include <iostream>
#include <cstring>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
#define MB (1024*1024)
int main()
@lablnet
lablnet / c_print.py
Last active August 7, 2020 09:01
Enable coloured print in python
"""c_print.py: Enable coloured print."""
__author__ = "Muhammad Umer Farooq"
__license__ = "MIT"
__version__ = "1.0.0"
__maintainer__ = "Muhammad Umer Farooq"
__email__ = "[email protected]"
__status__ = "Production"
def c_print(msg, color=None):
@lablnet
lablnet / ddos_attack.py
Last active August 24, 2020 07:29
python script to DDoS attack to any server, i will not accept any illegal usage of this script
"""ddos_attack.py: A python script to DDoS attack to any server."""
__author__ = "Muhammad Umer Farooq"
__license__ = "MIT"
__version__ = "1.0.0"
__maintainer__ = "Muhammad Umer Farooq"
__email__ = "[email protected]"
__status__ = "Production"
"""
DDoS: https://en.wikipedia.org/wiki/Denial-of-service_attack
Caution: i will not accept any illegal usage of this script, this is
@lablnet
lablnet / gcd.py
Created August 24, 2020 10:58
Pythonic way to find GCD.
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
print(gcd(int(input("Enter value of a: ")), int(input("Enter value of b: "))))
<VirtualHost *:80>
ServerName git.muhammadumerfarooq.com
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
SetEnv proxy-sendcl
ProxyPreserveHost On
ProxyPass /git http://127.0.0.1:3000/
INTEGER, PLUS, MINUS, MULTIPLY, DIV, EOF = 'INTEGER', 'PLUS', 'MINUS', 'MULTIPLY', 'DIV', 'EOF'
class Token():
def __init__(self, type, value):
self.type = type
self.value = value
def __str__(self):
return 'Token({type}, {value})'.format(
@lablnet
lablnet / Range.py
Last active October 23, 2020 10:03
Replicate of python range class in Python Class `Range` to understand how it works under the hood.
class Range:
def __init__(self, start, stop=None, step=1):
if step == 0:
raise ValueError("Step can not be zero.")
if stop is None:
start, stop = 0, start
# calculate the effective length once
self.length = max(0, ((stop - start) + (step - 1)) // step)
@lablnet
lablnet / task03.cpp
Last active October 14, 2020 09:22
Lab 02 tasks
//
// Created by lablnet on 10/14/20.
//
#include <iostream>
// we can use C++ vector to make it dynamic size but that was not requirement.
struct Weather {
float totalRainFall[6];
float temp[6];
float lowTemp[6];
import 'dart:async';
Future longRunningOperation() async {
for (int i = 0; i < 5; i++) {
await Future.delayed(Duration(seconds: 1));
print("index: $i");
}
}
main() {
@lablnet
lablnet / string.py
Created October 23, 2020 10:02
Simple list of python functions to manipulate strings and understand how they can works!q
def _to_lower(text: str) -> str:
upper = ""
for i in text:
if 65 <= ord(i) <= 90:
upper += chr(ord(i) + 32)
else:
upper += i
return upper