Skip to content

Instantly share code, notes, and snippets.

@navin-mohan
navin-mohan / dining_philosophers.c
Created October 22, 2017 18:14
Dining Philosophers problem in C
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
/*
use the pthread flag with gcc to compile this code
~$ gcc -pthread dining_philosophers.c -o dining_philosophers
@navin-mohan
navin-mohan / producer_consumer.c
Last active January 4, 2023 19:44
Producer-Consumer problem in C using semaphores
// MIT License
// Copyright (c) 2022 Navin Mohan
// 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, subject to the following conditions:
@navin-mohan
navin-mohan / mec_proxy_apt.conf
Created August 25, 2017 05:26
Apt conf for mec proxy
# /etc/apt/apt.conf
Acquire::http::Proxy "http://mec:mec@192.168.0.4:3128";
@navin-mohan
navin-mohan / Sources.list
Created August 18, 2017 17:38
Debian sources
#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://deb.debian.org/debian/ stable main contrib non-free
deb-src http://deb.debian.org/debian/ stable main contrib non-free
deb http://deb.debian.org/debian/ stable-updates main contrib non-free
deb-src http://deb.debian.org/debian/ stable-updates main contrib non-free
@navin-mohan
navin-mohan / codeblocks.md
Last active August 15, 2017 10:19
CodeBlocks

Installing CodeBlocks

On Windows XP / Vista / 7 / 8.x / 10

Download the installer from any of the links below.

It includes both the compiler(gcc) and IDE.

Ubuntu

@navin-mohan
navin-mohan / helper_functions.py
Last active June 11, 2017 10:45
Helper Functions for ML
# Python 3
import numpy as np
from PIL import Image
from io import BytesIO
from IPython import display
def split_test_train(dataset,percent):
'''Randomly splits the data set into test and train sets'''
@navin-mohan
navin-mohan / SimpleCalc.java
Created June 4, 2017 16:45
Calculator Applet using AWT Java
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class SimpleCalc extends Applet{
private Label xInputLabel,yInputLabel;
private Label statusLabel;
private Panel xInputPanel;
@navin-mohan
navin-mohan / WordCount.java
Last active June 4, 2017 14:01
Count the number of words in a file using Regex in Java
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
public class WordCount{
public static void main(String[] args) {
@navin-mohan
navin-mohan / bankers.ipynb
Last active May 30, 2017 18:40
Banker's Algorithm
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@navin-mohan
navin-mohan / vm.md
Created April 22, 2017 16:01
setting up vm ware and virtualbox on ubuntu

Installing VM Ware on Ubuntu

Getting VM Ware

Download the VM Ware Player bundle from here.

Install Dependencies

VM Ware requires the build tools to compile it's kernel modules. So let's install them.