Skip to content

Instantly share code, notes, and snippets.

View aarti's full-sized avatar
🎯
Focusing

aarti

🎯
Focusing
  • San Francisco Bay Area
View GitHub Profile
@aarti
aarti / make_gifs.go
Created January 6, 2017 02:29
Convert Gif's to PingPong Gif's
package main
import (
"bytes"
"image"
"image/gif"
"io/ioutil"
"log"
"net/http"
"sort"
@aarti
aarti / web-crawler.go
Last active December 31, 2016 07:47
Golang Tour Exercise: parallelize a web crawler. This implementation is using an html parser to scan href's.
package main
import (
"fmt"
"log"
"net/http"
"golang.org/x/net/html"
)
/*
Design a Rate Printer
The printer reads from a file
The printer writes to a file
Print the Bytes/Second at which the printer is printing every second
*/
package main
import (
"fmt"
def deserialize(input)
h = {}
l = 0
stack = []
curr_string = ""
while l < input.length do
case input[l]
when "{" #state = DICT_START
curr_string = ""
when ":" #state = VALUE_START
@aarti
aarti / connect_four.go
Created September 19, 2016 00:51
connect 4 in Go
package main
import (
"fmt"
"math/rand"
"os"
"regexp"
"strconv"
"strings"
)
@aarti
aarti / print array or slice
Created September 5, 2016 03:45
go generic print cannot print array
gore> a:=[]int{1,2,3}
[]int{1, 2, 3}
gore> println(a)
[3/3]0xc420041f20
gore> b:=[3]int{1,2,3}
[3/3]0xc420041ef8
[3]int{1, 2, 3}
gore> println(b)
# command-line-arguments
/var/folders/r0/xqky0mq5773d6bc44pk_xfb00000gp/T/705406632/gore_session.go:10: illegal types for operand: print
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"image/jpeg"
"image/png"
"math/rand"
@aarti
aarti / BreakStringIntoWords
Created September 30, 2015 05:45
Break a string Into valid words
class BreakStr
attr_reader :tree
def initialize
@tree = {}
@dict = ["I", "am", "a", "happy", "hap", "sad", "silly", "with"]
end
def get_valid_prefixes(word)
def max_slice(a)
max_start,max_end = 0,0
largest_sum = 0
curr_start,curr_end = 0,0
curr_sum = 0
for i in 0..a.length-1
if (curr_sum + a[i] < 0 ) then
curr_start = i+1
curr_sum = 0
elsif (curr_sum + a[i] > curr_sum) then
var Fib = {
compute: function(n) {
return n < 2 ? 1 : Fib.compute(n-1)+Fib.compute(n-2)
}
}
function memoize(obj,prop) {
var cache = {}
var fn = obj[prop]
return function(x) {