Skip to content

Instantly share code, notes, and snippets.

View harsh183's full-sized avatar
😺
People pleasing users

Harsh Deep harsh183

😺
People pleasing users
View GitHub Profile
import java.util.Random;
public class GameShow
{
public static void main()
{
Random r= new Random();
int stayResult=0;
int switchResult=0;
for(int x=0;x<100000;x++)
{
# Basic implementation of the monty hall problem based on
# http://mathforum.org/dr.math/faq/faq.monty.hall.html
#
# Harsh Deep
# 18.7.2016
# This is a acceptable door configuration, :goat means that there is a goat
# behind and :car means that there is a car behind.
doors = [:goat, :car, :goat]
@harsh183
harsh183 / hacker.rb
Created October 21, 2016 15:57
Movie level backer bs
require 'faker'
puts "Exit via Control-C (it's safe)"
puts "Best run with green text and black background (Mac terminal: Homebrew)"
# Messages per second
# Takes the speed from the command line arguement, if not given takes 50
if ARGV[0].nil?
puts "No given speed so taking 50 messages a second"
puts
@harsh183
harsh183 / numbersToWords.rb
Last active November 5, 2017 11:03
To convert number to words in ruby (for any positive integer)
def toWords(num)
units = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']
tens = ['', '', 'Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']
teens = ['Ten', 'Eleven', 'Tweleve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen',
'Seventeen', 'Eighteen', 'Nineteen']
units_digit = num % 10
tens_digit = num / 10
number_in_words = ""
@harsh183
harsh183 / turing-machine-simple-simulator.rb
Created March 2, 2018 20:09
Turing machine simple simulator
# Turing machine simulator - Inspired by Kill All Software screencast
# Guide to symbols:
# B: Blank. All the values of the tape are initally Blank
# L: Left. For the pointer to move Left
# R: Right. For the pointer to move right
# s{n}: State number {n}, ex. s1, s2, s3
def simulate(instructions)
# Initial state of the tape
@harsh183
harsh183 / guide.md
Created November 5, 2018 08:24
A noob's guide to fast.ai on VectorDash

VectorDash guide for Fasth AI (for Noobs, by Noobs, of Noobs)

Last updated: 2018-11-4

Okay I saw this on reddit a while back here

It's like digital ocean but GPU, neat and really simple to setup. My notes on this and some bash scripts I guess.

I'm a bit salty there is no persistent storage, but the net is fast so I think I can work around that.

Setup

@harsh183
harsh183 / uiuc-google-login.rb
Created January 15, 2019 02:44
This script uses selenium to login into uiuc's google apps login.
require 'watir'
require 'webdrivers'
@browser = Watir::Browser.new :firefox
# Standard google apps login page
@browser.goto("https://accounts.google.com/signin/v2/identifier?hl=en&passive=true&continue=https%3A%2F%2Fwww.google.com%2F&flowName=GlifWebSignIn&flowEntry=ServiceLogin")
# First pass google (google is weird, my input field selectors weren't )
@browser.send_keys "hdeep2@illinois.edu" # Can be anything that exists
@harsh183
harsh183 / Dockerfile
Last active July 28, 2020 10:54
Single chain rabbitMQ for distributed ruby task (here squaring and then cubing the number) - bit of copy paste but you get it
FROM rabbitmq:3.7.7-alpine
run rabbitmq-plugins enable --offline rabbitmq_web_stomp
run \
echo 'loopback_users.guest = false' >> /etc/rabbitmq/rabbitmq.conf && \
echo 'web_stomp.ws_frame = binary' >> /etc/rabbitmq/rabbitmq.conf
EXPOSE 15674
@harsh183
harsh183 / uiuc-course-explorer-direct-search.user.js
Last active March 14, 2021 22:16
UIUC Course Explore Direct Search Modification. Normally the UIUC Course Website search bar doesn't directly let you go to the Course page directly as the search bar only takes the department. This adds the functionality without breaking any existing usage.
// ==UserScript==
// @name UIUC course explorer direct enter course number
// @version 1
// @grant none
// ==/UserScript==
// @author Harsh Deep <harsh183>
// @date 2019-05-04
// @for https://courses.illinois.edu/*
@harsh183
harsh183 / paul_graham_site_improve.user.js
Created May 5, 2019 07:12
Opinated userscript that makes Paul Graham's website slightly nicer to me to read since I go there a lot.
// ==UserScript==
// @name Paul Graham website beautifier
// @version 1
// @grant none
// ==/UserScript==
// Based off http://bettermotherfuckingwebsite.com/
var styles = `
body {