Skip to content

Instantly share code, notes, and snippets.

Avatar

Santosh Kumar santosh

View GitHub Profile
@santosh
santosh / copy-from-bucket-to-bucket.go
Last active Sep 11, 2020
Some fiddling with AWS Go's SDK. Experiments done with S3.
View copy-from-bucket-to-bucket.go
package main
import (
"fmt"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
@santosh
santosh / data.txt
Last active Sep 10, 2020
Plotting in Go with gonum/plot.
View data.txt
6.1101,17.592
5.5277,9.1302
8.5186,13.662
7.0032,11.854
5.8598,6.8233
8.3829,11.886
7.4764,4.3483
8.5781,12
6.4862,6.5987
5.0546,3.8166
@santosh
santosh / github.go
Last active Sep 5, 2020
Webpage OAuth flow example with GitHub.
View github.go
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
)
const clientID = "<your client id here>"
@santosh
santosh / worker_pool.go
Created Aug 18, 2020
Worker pool with buffered channel.
View worker_pool.go
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
// Worker pool is a collection of threads which are waiting
View advance_level_programming.md
  • Add concurrency.
  • Now deal with it.
  • Mutexes, somaphores, context switching
  • Check for race condition.
@santosh
santosh / interface.go
Last active Jul 7, 2020
Getting started with interfaces.
View interface.go
package main
import "fmt"
type SalaryCalculator interface {
CalculateSalary() int
}
type Permanent struct {
empId int
@santosh
santosh / docker_postgres.md
Last active May 20, 2020
Basic docker postgres setup for dev.
View docker_postgres.md
docker run -d --name postgres -e POSTGRES_PASSWORD=Pass2020! -v postgres-data:/var/lib/postgresql/data -p 5432:5432 postgres:11-alpine

More env vars at https://hub.docker.com/_/postgres.

Hop into the container:

docker exec -it postgres bash

And use the psql repl.

@santosh
santosh / description.md
Created Apr 29, 2020
How to test this func in handler.go?
View description.md

I can run those tests on my local machine where I have mongo instance spinned up. But what about CI/CD services like Travis-CI?

How do I approach this?

@santosh
santosh / usestate.js
Created Mar 16, 2020
Using states in functional components.
View usestate.js
function App() {
const [count, setCount] = React.useState(0)
function increment() {
setCount(prevCount => prevCount + 1)
}
function decrement() {
setCount(prevCount => prevCount - 1)
}
View reactforms.js
class App extends React.Component {
constructor() {
super()
this.state = {
firstName: "",
lastName: "",
age: null,
location: "",
gender: "",
dietaryRestrictions: {