Skip to content

Instantly share code, notes, and snippets.

@yogesh-desai
yogesh-desai / FindMaximumPossibleNumberByDeletingDigit5.go
Last active October 7, 2021 16:45
Write a function solution that, given an integer N, returns the maximum possible value obtained by inserting one '5' digit inside the decimal representation of integer N. if N= 5859 output= 589. if N= -5859 output= -859 If N = -5000 ouput =0
package main
import (
"fmt"
"strconv"
)
func main() {
fmt.Println(Solution(-5000))
@yogesh-desai
yogesh-desai / cache-benchmarking.
Created May 30, 2019 18:55
This compares various caches.
package gocachebenchmarks
import (
"fmt"
"strconv"
"sync"
"testing"
"time"
"github.com/allegro/bigcache"
package main
import (
"golang.org/x/net/html"
"net/http"
"net/url"
"runtime"
"strings"
"context"
package main
import (
"net/http"
"net/url"
"runtime"
"strings"
"context"
"bytes"
@yogesh-desai
yogesh-desai / googlecdp.go
Created September 13, 2017 08:21
Chromdp to use iframes
package main
import (
"context"
"io/ioutil"
"log"
"time"
"fmt"
cdp "github.com/knq/chromedp"
@yogesh-desai
yogesh-desai / struct_as_map_key.go
Created November 16, 2016 19:19 — forked from cevaris/struct_as_map_key.go
Golang: Using structs as key for Maps
package main
import "fmt"
type A struct {
a, b int
}
func MapStructValAsKey(){
// Notice: We are using value of `A`, not `*A`
@yogesh-desai
yogesh-desai / readLines-writeLines.go
Created October 19, 2016 15:56 — forked from wofeiwo/readLines-writeLines.go
read lines write lines like python api in golang
package main
import (
"io"
"os"
"bufio"
"bytes"
"fmt"
"strings"
)
@yogesh-desai
yogesh-desai / date_loop.sh
Created June 25, 2016 13:54 — forked from chluehr/date_loop.sh
Bash: Loop over dates
#!/bin/bash
now=`date +"%Y-%m-%d" -d "05/06/2012"`
end=`date +"%Y-%m-%d" -d "05/23/2012"`
while [ "$now" != "$end" ] ;
do
now=`date +"%Y-%m-%d" -d "$now + 1 day"`;
echo $now
done
@yogesh-desai
yogesh-desai / exercise.tour.go
Created October 23, 2015 10:44 — forked from zyxar/exercise.tour.go
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)
@yogesh-desai
yogesh-desai / README.md
Last active August 29, 2015 14:24 — forked from mtowers/README.md