Skip to content

Instantly share code, notes, and snippets.

View souvikhaldar's full-sized avatar
🌴
On vacation

Souvik Haldar souvikhaldar

🌴
On vacation
View GitHub Profile
package main
import "fmt"
func main() {
ch := make(chan int, 2)
ch <- 1
ch <- 2
ch <- 3
fmt.Println(<-ch)
package main
import (
"fmt"
"time"
)
func fibonacci(n int, c chan int) {
x, y := 0, 1
for i := 0; i < n; i++ {
package main
import "fmt"
func fibonacci(c, quit chan int) {
x, y := 0, 1
for {
select {
case c <- x:
x, y = y, x+y
case <-quit:
package main
import (
"fmt"
"sync"
"time"
)
// SafeCounter is safe to use concurrently.
type SafeCounter struct {
package main
import (
"fmt"
)
func appendCategory(a []string, b []string) []string {
check := make(map[string]int)
d := append(a, b...)
@souvikhaldar
souvikhaldar / intreverse.py
Created February 12, 2019 17:37
Function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.
def intreverse(n):
a=""
while n>0:
b=str(n%10)
a=a+b
n=n//10
return int(a)
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus.yml
[Install]
WantedBy=multi-user.target
global:
scrape_interval: 15s
# By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['<TARGET_IP>:9100']
@souvikhaldar
souvikhaldar / qr.py
Last active January 27, 2020 17:15
How to generate QR code of any text data in python3
# Importing the module pyqrcode
import pyqrcode
# data for the QR code
s = input("Enter the data to be put in the QR code: ")
# Generate QR code by the help of create function
url = pyqrcode.create(s)
# name of the geneated file
name = input("Enter name for the generated image file: ")
filename = name + ".svg"
url.svg(filename, scale = 8)