Skip to content

Instantly share code, notes, and snippets.

import random
def generate_social_network(num_people=10, num_connections=15):
people = [f"Person_{i}" for i in range(num_people)]
connections = []
for _ in range(num_connections):
person1, person2 = random.sample(people, 2)
if (person1, person2) not in connections and (person2, person1) not in connections:
connections.append((person1, person2))
import random
def generate_employee_reporting(num_employees=10):
employees = [f"Employee_{i}" for i in range(num_employees)]
reporting = []
for i in range(1, num_employees):
manager = random.choice(employees[:i])
reporting.append((manager, employees[i]))
import random
def generate_city_transport_network(num_stations=10, num_routes=15):
stations = [f"Station_{i}" for i in range(num_stations)]
routes = []
for _ in range(num_routes):
station1, station2 = random.sample(stations, 2)
routes.append((station1, station2))
import pandas as pd
import random
# Define departments and create a sample hierarchy
departments = [
'Executive', 'Finance', 'HR', 'IT', 'Marketing', 'Sales', 'Engineering',
'Customer Service', 'Product Development', 'Legal', 'Operations', 'R&D'
]
# Generate random hierarchy relationships
import pandas as pd
import random
# Define departments and projects
departments = ['HR', 'Engineering', 'Sales', 'Finance', 'Marketing', 'IT']
projects = [f'Project {chr(65 + i)}' for i in range(20)] # Creates projects A to T
# Generate random department-project associations
data = []
for project in projects:
@davidrajm
davidrajm / plot_helper.py
Last active April 23, 2021 17:51
This helper script will give a function to plot the given vectors. One can input the 2-tuple vectors in an array and get the plot of them.
def plot_vectors(vectors, title=None):
import numpy as np
from matplotlib import pyplot as plt
# Initiate the plot
fig, ax = plt.subplots(figsize = (5,5))
# Draw each vector as quiver plot
for x_cor, y_cor in vectors:
ax.quiver(0,0,x_cor,y_cor,
scale=1,angles='xy',
@davidrajm
davidrajm / index.html
Created January 13, 2021 10:27
Complete Code for render Math Dynamically using MathJax
<!DOCTYPE html>
<html lang="en">
<head>
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<title>MathJax</title>
<style>
.container{
max-width: 900px;
margin:0 auto;
@davidrajm
davidrajm / index.html
Created January 13, 2021 06:20
Initial Setup for MathJax CDN
<!DOCTYPE html>
<html lang="en">
<head>
<script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<title>MathJax</title>
</head>
<body>
<div class="container">
$$ x = -b \pm \frac{\sqrt{b^2 - 4ac}}{2a}$$
</div>
@davidrajm
davidrajm / countries.sql
Created August 15, 2019 17:19 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;