Skip to content

Instantly share code, notes, and snippets.

View farooqkz's full-sized avatar

Farooq Karimi Zadeh farooqkz

View GitHub Profile
@farooqkz
farooqkz / look.pl
Last active December 13, 2017 15:52
More advanced look utility
#!/usr/bin/perl -Tw
##############################################################################
#
# Copyright (C) 2017 Farooq Karimi Zadeh <farooghkarimizadeh@gmail.com>
#
# 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
# copies of the Software, and to permit persons to whom the Software is
@farooqkz
farooqkz / vigenere.c
Last active December 13, 2017 15:55
Something like Vigenere cipher but for bytes instead of letters
/*
Vigenere File Coder and Decoder
Copyright (C) 2017 Farooq Karimi Zadeh <farooghkarimizadeh@gmail.com>
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 copies of the Software,
and to permit persons to whom the Software is furnished to do so,
@farooqkz
farooqkz / hexview.py
Last active December 13, 2017 15:55
simple file viewer in hex format. usage: hexview.py <filename>
#!/usr/bin/python3
'''
HexView.Py - A simple File Viewer in Hexadecimal format.
Author: FarooqKZ
Under GPL3+. THIS SOFTWARE COMES WITH NO WARRENTY FROM MAIN AUTHOR.
'''
import sys # I inlcude this to use sys.exit() and sys.argv
@farooqkz
farooqkz / hexview.c
Last active December 13, 2017 15:55
Simple file viewer in hex format. usage: hexview <filename>
// hexview.c
// Author: FarooqKZ
// It's free software under GPL3+ and comes WITHOUT ANY WARRENTY FROM MAIN AUTHOR
#include <stdio.h>
int main(int argc, char *argv[]){
if (argc == 1 || !strcmp(argv[1], "-h")){
printf("Usage: hexview file_path\n");
return 0;
}
@farooqkz
farooqkz / m234.py
Created December 27, 2017 15:01
-
#!/usr/bin/python3.5
# Hi, I am a program who select a random element from S n times.
# you should specify n via m234.py n
# My father is Farooq KZ
# You can contact him at farooghkarimizadeh@gmail.com
# Also I'm under MIT/X11 licence
import os # I want it for os.urandom
import sys # I want it for sys.argv and sys.exit
@farooqkz
farooqkz / get_pubip_from_router.py
Created December 29, 2017 10:13
A small script to get my public IP from my router/modem
import telnetlib
PASSWORD = "admin" # change these two
ADDR = "192.168.1.1"
t = telnetlib.Telnet(host=ADDR)
t.read_until("Password:".encode())
t.write((PASSWORD + "\r\n").encode())
t.read_until("TP-LINK> ".encode())
t.write("show wan status\r\n".encode())
import cherrypy
class Hello:
@cherrypy.expose
def index(self, key=""):
if key == "":
return "Hello. Please enter key. [Some form here with textbox and submit button and perhaps some fancy features...]"
elif key == "THE SECRET KEY":
return "Hello you have entered the right key!"
else:
@farooqkz
farooqkz / form-based-auth.py
Last active July 28, 2020 11:54
Form based auth with CherryPy using sessions
# Code is by Farooq Karimi Zadeh
# and it is under CC0 which means
# Public Domain and no copyright :)
import cherrypy # <3
@cherrypy.tools.register('before_handler')
def myauth():
sess = cherrypy.session
if sess.get("login?"):
return "Mooo" # It should just return, not important what it returns
@farooqkz
farooqkz / clean_html.py
Last active November 6, 2020 19:22
Clean HTML tags attributes(except IMG's src and A's href) and remove DIVs. Good for converting HTMLs to Markdown
# Code by Farooq Karimi Zadeh <fkz@riseup.net>
# Under CC0 1.0
from html.parser import HTMLParser
class MyParser(HTMLParser):
def handle_starttag(self, tag, attrs):
attrs = dict(attrs)
if tag == "img":
src = attrs["src"] if "src" in attrs else ""
class Customer:
account = Account()
name = "Far the chickenkiller"
...
class Account:
no = ... # some big integer
rials = 10000 # 1000 toman
dollars = 1.0 # one dollar only