Skip to content

Instantly share code, notes, and snippets.

View Hypro999's full-sized avatar

Hemanth V. Alluri Hypro999

View GitHub Profile
@Hypro999
Hypro999 / PyStudentDatabase.py
Last active December 26, 2022 18:46
The data is in the form of a list which subsequently contains dictionaries - code snippet for saving and loading. The idea for PyStudentManager was inspired by Bo Milanovich in his Pluralsight course. Note: I made this a long while ago when I was new to programming (in general, but more specifically in Python) which is why the code may cause you…
import time
students = []
# Titlecasing:
def get_students_tica():
students_tica = []
i = 0
@Hypro999
Hypro999 / djano_extra_init.py
Last active October 26, 2021 06:26
A small script to do some initialization for your django app.
""" To be executed from within your django application for extra initialization """
import os
def touch_init(directory_name, alt="__init__.py"):
target = os.path.join(directory_name, alt)
with open(target, "a+") as f:
print("touching file: {}".format(target))
f.close()
@Hypro999
Hypro999 / GetRequest.java
Last active January 16, 2020 09:37
An example of how to make a GET request in Java then using the GSON library to format the response data (JSON).
import java.net.URL;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@Hypro999
Hypro999 / sendmail.py
Created July 5, 2019 13:52
A simple (insecure) example using Python's smtplib library to send mail using gmail as a provider.
#!/bin/bash/python3
import sys
import smtplib
import getpass
server_name = 'smtp.gmail.com'
payload = """From: {}
To: {}
Subject: Hello world!
@Hypro999
Hypro999 / gsoc_2019_work_product.md
Last active February 15, 2020 07:48
My final submission for GSoC 2019 explaining the work I've done.

Google Summer of Code 2019 with The Zulip Open Source Project


Introduction

Google Summer of Code (GSoC) is a summer internship program arranged by Google

@Hypro999
Hypro999 / bppc-question-papers-parser.py
Last active January 16, 2020 09:30
BITS Pilani Question Papers Parser: Automatically scan all links in the library's portal's question papers section to find the question papers you want.
#!/usr/bin/env python3
import os
import sys
import requests
from getpass import getpass
from typing import List
from bs4 import BeautifulSoup
@Hypro999
Hypro999 / docker-clear.sh
Created December 31, 2019 06:01
A simple, naive bash script to clear out intermediate docker images after building one.
#!/bin/bash
# Inspired by nnsense's answer at https://forums.docker.com/t/how-to-remove-none-images-after-building/7050/16
if [ $# -ne 1 ]; then
echo "You must enter a single valid image id or name."
else
# Assume that the image id/name is actually valid.
docker save --output /tmp/image.tar $1
docker image rm $1
docker image prune # Just an extra cleanup step while we're at it.
docker load --input /tmp/image.tar
@Hypro999
Hypro999 / apache2-sample.conf
Last active January 16, 2020 09:28
A sample virutalhost configuration file in Apache2.
<VirtualHost 127.0.1.2:80>
ServerName testme.net
ServerAlias www.testme.net
DocumentRoot /home/hemanth/Code/PHP/testme.net
ErrorLog /home/hemanth/Code/PHP/testme.net/logs/error.log
<Directory "/home/hemanth/Code/PHP/testme.net">
Require all granted
</Directory>
@Hypro999
Hypro999 / daemonize.c
Last active December 16, 2020 15:49
A program written in C which demonstrates how to daemonize a process in the Unix environment using system calls.
/* Disclaimer: glibc provides the deamon(3) library function as a part of
Linux and should be prefered over writing ad-hoc boiler plate code like
this. Though this C example *does* provide a good demonstration of the steps
to be taken to daemonize a process via. system calls in Unix especially since
deamon(3) is not a POSIX.1. standard function. */
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
@Hypro999
Hypro999 / logmuncher.go
Last active August 14, 2020 15:05
A simple concurrent go program to clear out (log)files.
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"sync"