Skip to content

Instantly share code, notes, and snippets.

// node class
class Node {
constructor(value, left, right) {
this.value = value
this.left = left
this.right = right
}
}
@student020341
student020341 / flatten_a.rb
Created May 8, 2018 02:47
flatten an arbitrarily nested array with ruby
# let's pretend we're building a web service - incoming data (ARGV[0]) will probably be a json string
require 'json'
# define some tests to run in case there is no input
inputs = [
[1, 2, 3, 4],
[1, 2, [3, 4]],
[1, [2, [3, 4]]],
# this program might actually be useful
[1, [2, [[[[[5]]]]]]],
@student020341
student020341 / sus.go
Created November 10, 2016 23:39
Script to suspend a computer when there has been no user activity for 30 minutes and there is no media playing.
package main
import (
"os/exec"
"strconv"
"time"
)
//determine if the user has been idle for a certain amount of time
func deadTime() bool {