Skip to content

Instantly share code, notes, and snippets.

View rajesnal's full-sized avatar

Rajesh Kumar Nallabanda rajesnal

View GitHub Profile
@rajesnal
rajesnal / dynamic_plotting.py
Created June 23, 2018 16:30 — forked from greydanus/dynamic_plotting.py
Dynamic plotting for matplotlib
"Dynamic plotting in matplotlib. Copy and paste into a Jupyter notebook."
# written October 2016 by Sam Greydanus
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
import time
def plt_dynamic(x, y, ax, colors=['b']):
for color in colors:
ax.plot(x, y, color)
@rajesnal
rajesnal / golang_job_queue.md
Created April 12, 2018 12:05 — forked from harlow/golang_job_queue.md
Job queues in Golang
@rajesnal
rajesnal / main.go
Created April 12, 2018 11:59 — forked from nesv/main.go
package main
import (
"flag"
"fmt"
"net/http"
)
var (
NWorkers = flag.Int("n", 4, "The number of workers to start")
@rajesnal
rajesnal / worker.go
Created April 12, 2018 11:59 — forked from nesv/worker.go
package main
import (
"fmt"
"time"
)
// NewWorker creates, and returns a new Worker object. Its only argument
// is a channel that the worker can add itself to whenever it is done its
// work.
package main
import (
"fmt"
"net/http"
"time"
)
// A buffered channel that we can send work requests on.
var WorkQueue = make(chan WorkRequest, 100)
@rajesnal
rajesnal / work.go
Created April 12, 2018 11:57 — forked from nesv/work.go
package main
import "time"
type WorkRequest struct {
Name string
Delay time.Duration
}
package main
import "fmt"
var WorkerQueue chan chan WorkRequest
func StartDispatcher(nworkers int) {
// First, initialize the channel we are going to but the workers' work channels into.
WorkerQueue = make(chan chan WorkRequest, nworkers)
@rajesnal
rajesnal / fifo.go
Created January 7, 2018 07:28 — forked from edhemphill/fifo.go
Thread / goroutine safe, batching and blocking FIFO queue in golang
import (
"net/http"
"sync"
"fmt"
)
type logBuffer struct {
stuff string
}