Skip to content

Instantly share code, notes, and snippets.

View PratikDeoghare's full-sized avatar

Pratik Deoghare PratikDeoghare

View GitHub Profile
@PratikDeoghare
PratikDeoghare / dict.go
Created July 20, 2025 11:33
a naughty golang program ;-)
// https://go.dev/play/p/pCVgS47-yNt
package main
import (
"encoding/json"
"fmt"
)
type dict map[string]any
import code, os, sys
prompt = '> '
def read_fork():
global prompt
while True:
s = input(prompt)
s = s.strip()
if s == 'fork' or s == 'whatif':
@PratikDeoghare
PratikDeoghare / product1.go
Created September 13, 2024 21:45
itertools.product in golang
package main
import (
"fmt"
"testing"
)
func product(xss [][]int) [][]int {
if len(xss) == 0 {
return nil
@PratikDeoghare
PratikDeoghare / pwc.go
Last active June 18, 2023 07:36
Approximate Word Counter
package main
import (
"flag"
"fmt"
"io"
"math/rand"
"os"
"regexp"
"sort"
/**
* Naive goroutines lookalike in Scala.
*
*/
import scala.concurrent._
import scala.concurrent.duration.Duration
@PratikDeoghare
PratikDeoghare / zbell.sh
Created March 24, 2023 16:13 — forked from jpouellet/zbell.sh
Makes Zsh print a bell when long-running commands finish. I use this in combination with i3 and throw big compile jobs (or whatever it may be) into another workspace to get a nice visual notification (workspace indicator turns red) when it's done so I don't need to waste time regularly checking on it.
#!/usr/bin/env zsh
# This script prints a bell character when a command finishes
# if it has been running for longer than $zbell_duration seconds.
# If there are programs that you know run long that you don't
# want to bell after, then add them to $zbell_ignore.
#
# This script uses only zsh builtins so its fast, there's no needless
# forking, and its only dependency is zsh and its standard modules
#
@PratikDeoghare
PratikDeoghare / slice
Created July 21, 2022 07:22
get range of chars from file
#! /usr/bin/env python3
import sys
f = sys.stdin
if len(sys.argv) == 4:
f = open(sys.argv[3])
a = int(sys.argv[1])
b = int(sys.argv[2])
@PratikDeoghare
PratikDeoghare / madlogger.deployment.yaml
Last active July 11, 2022 15:34
Pod to produce lots of random log messages
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: madlogger
name: madlogger
namespace: kube-system
spec:
replicas: 30
selector:
@PratikDeoghare
PratikDeoghare / serial-logger.go
Created May 27, 2022 14:46
Serialize golang test logs when t.Parallel is used
package main
import (
"flag"
"fmt"
"io/ioutil"
"sort"
"strings"
)
@PratikDeoghare
PratikDeoghare / ports
Created February 11, 2022 08:44
ways of generating ports
package main
import (
"fmt"
"sync"
"time"
)
func main() {
newPort := func() func() int {