Skip to content

Instantly share code, notes, and snippets.

View keshavsaharia's full-sized avatar

Keshav Saharia keshavsaharia

View GitHub Profile
@keshavsaharia
keshavsaharia / PERL - web power switch
Last active November 27, 2021 17:55
PERL script for communicating with the Digital Loggers Web Power Switch that uses a simple decomposition-based natural language parser.
my $cmd = "";
my $base = "/path/to/dlogger.pl"; # Change this to the path where the provided PERL utility is kept
my $auth = " admin:1234"; # Change this to the authentication you use to log in to your switch
my $status = "";
my $buffer = "";
my $temp = "";
my @outlets;
my @outletstatus;
@keshavsaharia
keshavsaharia / NeuralNetwork.wl
Last active April 21, 2017 13:14
A neural network implemented in Mathematica.
(* A neuron is a list, where the first element is the value, and the remaining elements are weights of
incoming connections to the neuron. Neurons are constructed by specifying the number of incoming synapses *)
Neuron[i_] := {0} ~Join~ ((2*RandomReal[] - 1) & /@ Range[i]);
(* Create a neuron with the specific weight and set of edges *)
Neuron[v_, w_] := Join[{v}, w];
(* A layer of the network is just a list of neurons *)
Layer[n_, i_] := Array[Neuron[i] &, n];
@keshavsaharia
keshavsaharia / rainbowsort.java
Created October 18, 2014 22:11
Rainbow Sort
import zen.core.Zen;
public class RainbowSort {
// Just some utility stuff, leave these variables alone.
private static boolean visualized = false;
private static int size = 500, step = 1;
private static int min = 0, max = 0;
private static int[] cache;
// Creates an array and visualizes the sorting of it.

This is da readmeasdf

@keshavsaharia
keshavsaharia / README.md
Last active February 17, 2017 05:48
problem: Fizz Buzz

Fizz Buzz

Write a program that prints the numbers from 1 to 100. However, for multiples of three, print "fizz" instead of the number. For the multiples of five, print "buzz", instead of the number. For numbers which are multiples of both three and five, print "fizzbuzz".