Skip to content

Instantly share code, notes, and snippets.

View hackintoshrao's full-sized avatar
📚
Exploring AI agents on code search and understanding

Karthic Rao hackintoshrao

📚
Exploring AI agents on code search and understanding
View GitHub Profile
@hackintoshrao
hackintoshrao / mapAndStructAdd.go
Created June 23, 2015 10:17
Functions in which elements from maps and structs are accessed and added and later tested for their benchmark in a test file ,here is the link of the code form the repo https://github.com/Karthic-Hackintosh/Codes-From-My-Blog-posts/blob/master/121/bench1/mapAndStructAdd.go
package gobench
func GoMapAdd() {
m := map[int]int{0: 0, 1: 1}
_ = m[0] + m[1]
}
func GoStructAdd() {
m := struct{ a, b int }{0, 1}
_ = m.a + m.b
package gobench
import (
"testing"
)
func BenchmarkGoMapAdd(b *testing.B) {
for i := 0; i < b.N; i++ {
GoMapAdd()
@hackintoshrao
hackintoshrao / marshal.go
Created June 30, 2015 04:01
functions containing Marshal pf Map and Struct
package bench2
import (
"encoding/json"
)
func MarshalMap() {
m := map[int]int{0: 0, 1: 1}
json.Marshal(m)
}
@hackintoshrao
hackintoshrao / marshal_test.go
Created June 30, 2015 04:04
Benchmark for marshal.go
package bench2
import (
"testing"
)
func BenchmarkMarshalMap(b *testing.B) {
for i := 0; i < b.N; i++ {
MarshalMap()
package main
import (
"fmt"
"io/ioutil"
//"net/http"
//"time"
)
// NewWorker creates, and returns a new Worker object. Its only argument
from scipy.io.wavfile import read #import wav audio related functions
import matplotlib.pyplot as plt #for plotting
fs , x = read('/home/karthic/Downloads/kalimba.wav') #x is an array of integers containing all the samples of the wav file
print "sample rate = " ,fs #sample rate of the wav file
print "Total samples in the wav audio: ",x.size #total number of samples in the wav audio
print "Length of wav file in seconds: ",x.size/float(fs)
#number of samples / sampling rate gives the length of the wav file in seconds
plt.plot(x) #plot the wav sampling
@hackintoshrao
hackintoshrao / kafka_quick_hack.go
Last active August 28, 2017 09:54
A quick hack to get the Golang kafka driver to publish to "test" topic created from the quick start guide here http://kafka.apache.org/documentation.html#quickstart
package main
import (
"github.com/Shopify/sarama"
"crypto/tls"
"crypto/x509"
"encoding/json"
"flag"
"fmt"
@hackintoshrao
hackintoshrao / redirect.go
Created November 25, 2015 05:34
redirect.go with the global HTML string inside the middleware
// Package redirect is middleware for redirecting certain requests
// to other locations.
package redirect
import (
"fmt"
"html"
"net/http"
"github.com/mholt/caddy/middleware"
@hackintoshrao
hackintoshrao / fib.go
Created December 25, 2015 18:37
First version conatins inefficient code for finding fibonacci numbers
package main
import "fmt"
func main() {
fmt.Println(Fib(3))
}
//Fib inefficent version
func Fib(n int) int {
@hackintoshrao
hackintoshrao / fib_test.go
Created December 25, 2015 18:40
benchmark for the inefficient version one
package main
import (
"testing"
)
func BenchmarkFibV1(b *testing.B) {
// run the Fib function b.N times
for n := 0; n < b.N; n++ {
Fib(10)