Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
zsrinivas / TelnetServer.py
Last active October 5, 2023 09:48
Simple Telnet Echo Server and Telnet Client
import socket, threading
lock = threading.Lock()
clients = [] #list of clients connected
class TelnetServer(threading.Thread):
def __init__(self, (sock, address)):
threading.Thread.__init__(self)
self.socket = sock
self.address = address
@zsrinivas
zsrinivas / lighty.py3
Last active September 29, 2022 13:54
lighty
#!/usr/bin/env python3
from subprocess import call
import tempfile
import os.path
import socket
import sys
import mimetypes
from netifaces import interfaces, ifaddresses, AF_INET
types_map = {
@zsrinivas
zsrinivas / downsols.py
Created December 17, 2015 16:48
downloads spoj solutions
import os
import re
from getpass import getpass
from requests import Session
STATUS_PAGE = "http://www.spoj.com/status/{problem},{username}/"
MYACCOUNT_PAGE = "http://www.spoj.com/myaccount/"
SOLUTION_PAGE = "http://www.spoj.com/files/src/save/{sol_id}"
HOME_PAGE = "https://www.spoj.com/"
@zsrinivas
zsrinivas / database.py
Created March 1, 2015 14:48
spoj classical problems metadata
This file has been truncated, but you can view the full file.
database = [{'code': u'ABA12B', u'Resource': u'Own problem', 'users': u'34', u'Cluster': u'Cube (Intel Pentium G860 3GHz)', u'Added by': u'Kashyap Krishnakumar', 'name': u'String Factorization!', u'Languages': u'All except: SCM chicken', u'Time limit': u'0.073s-0.184s', u'Source limit': u'50000B', u'Memory limit': u'1536MB', u'Date': u'2012-01-10', 'id': u'10376', 'accuracy': u'11.04'},
{'code': u'ABA12C', u'Resource': u'Own problem', 'users': u'367', u'Cluster': u'Cube (Intel Pentium G860 3GHz)', u'Added by': u'Kashyap Krishnakumar', 'name': u'Buying Apples!', u'Languages': u'All except: SCM chicken', u'Time limit': u'0.148s', u'Source limit': u'50000B', u'Memory limit': u'1536MB', u'Date': u'2012-01-13', 'id': u'10394', 'accuracy': u'34.80'},
{'code': u'ABA12D', u'Resource': u'Own problem', 'users': u'1179', u'Cluster': u'Cube (Intel Pentium G860 3GHz)', u'Added by': u'Kashyap Krishnakumar', 'name': u'Sum of divisors!', u'Languages': u'All except: ASMGCC C++14 COB GROOVY NODEJS PYPY PYTH 3.2.3 n PY3.4 SCM c
378||Size Contest|SIZECON|7254|52.92
53||Kamil|KAMIL|4311|49.94
270||Digits of Pi|PIVAL|4094|65.82
314||Digits of e|EVAL|2022|68.13
1423||Digits of SQRT(2)|SQRT2|1945|64.84
919||Prime checker|PRIC|1323|71.91
3947||Brainf F##k Writing|BFWRITE|1196|76.51
11746||Sum the Series|SUMUP|1082|61.36
127||Johnny Goes Shopping|JOHNNY|968|65.73
5842||Polybius square|POLYBIUS|875|61.18
James Bond - 001 - Casino Royale - Ian Fleming.epub
James Bond - 002 - Live and Let Die - Ian Fleming.epub
James Bond - 003 - Moonraker - Ian Fleming.epub
James Bond - 004 - Diamonds Are Forever - Ian Fleming.epub
James Bond - 005 - From Russia with Love - Ian Fleming.epub
James Bond - 006 - Doctor No - Ian Fleming.epub
James Bond - 007 - Goldfinger - Ian Fleming.epub
James Bond - 008 - For Your Eyes Only - Ian Fleming.epub
James Bond - 009 - Thunderball - Ian Fleming.epub
James Bond - 010 - The Spy Who Loved Me - Ian Fleming.epub
set ns [new Simulator]
set f [open out.tr w]
set nf [open out.nam w]
$ns trace-all $f
$ns namtrace-all $nf
proc finish {} {
global f nf ns
$ns flush-trace
@zsrinivas
zsrinivas / ubuntu-gnome-16.04-setup.txt
Last active March 27, 2017 13:45
todo: after installing ubuntu-gnome-16.04
## ☐ ☑ ☒
☐ enable partner repositories
☐ install y-ppa-manager
☐ % sudo add-apt-repository -y ppa:webupd8team/y-ppa-manager
☐ % sudo apt-get update
☐ % sudo apt-get install y-ppa-manager
☐ media
☐ install vlc
@zsrinivas
zsrinivas / buglife.cc
Created February 5, 2015 14:52
spoj 3377. A Bug’s Life | BUGLIFE
#include <bits/stdc++.h>
using namespace std;
#define usingcincout ios::sync_with_stdio(0);cin.tie(0);
template <class T>
void gint(T& n) {
n = 0;
int sign=1;
register char c=0;
while(c<33)
@zsrinivas
zsrinivas / ctype-eightnoteight.h
Created May 27, 2014 09:57
My Implementation of ctype.h
/*
Author : eightnoteight
website : eightnoteight.wordpress.com
*/
int isalnum(char a){
return (a>='A'&&a<='Z')||(a>='a'&&a<='z')||(a>='0'&&a<='9');
}
int isalpha(char a){
return (a>='A'&&a<='Z')||(a>='a'&&a<='z');
}