Skip to content

Instantly share code, notes, and snippets.

View sudipidus's full-sized avatar
:bowtie:
clueless

Sudip Bhandari sudipidus

:bowtie:
clueless
View GitHub Profile
design a scheduler:
- schedule for a given time input->(fn, time)
- cron like schedule ( every night at 12:00 AM)
Functionality:
- configure
@sudipidus
sudipidus / gist:ad47624b29656e517ce0a1c7ff25faa9
Created March 5, 2024 07:15
Mac Kernel Panic (Catastrophic Error: Intel Hardware error), trigerred when I connected my phone to usb c port
panic(cpu 0 caller 0xfffffff0232dbf60): x86 CPU CATERR detected
Debugger message: panic
Memory ID: 0x6
OS release type: User
OS version: 21P3049
macOS version: 23D60
Kernel version: Darwin Kernel Version 23.3.0: Wed Dec 20 22:31:16 PST 2023; root:xnu-10002.81.5~10/RELEASE_ARM64_T8010
KernelCache UUID: 5055C553638BB2B9A72F9B074650402D
Kernel UUID: 98C51133-18A2-37CC-8054-0C2A5A0CC992
Boot session UUID: 80B9AC50-63B4-46D2-919C-AE0F9CFBC614
@sudipidus
sudipidus / prime_sieve.go
Created January 27, 2024 17:24
parallel prime number sieve in golang
// Communication Sequential Process (CSP) - Tony Hoare
// Finding Prime numbers using sieve in parallel
package main
import "fmt"
func main() {
src := make(chan int)
@sudipidus
sudipidus / rabbit_mq_sender.go
Created January 6, 2022 08:02
go script to send events to rabbit mq
package main
import (
"fmt"
"log"
amqp "github.com/rabbitmq/amqp091-go"
)
func failOnError(err error, msg string) {
@sudipidus
sudipidus / offending_logs.sh
Last active May 27, 2019 14:20
This script is to filter out the most recurring log messages. I faced an issue where syslog was rapidly increasing (35 GB) in a single day. I have /var/log mounted on root partition and this space usage was causing issue. Courtesy: https://askubuntu.com/a/515152/309358
for log in /var/log/{dmesg,syslog,kern.log}; do
echo "${log} :"
sed -e 's/\[[^]]\+\]//' -e 's/.*[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//' ${log} \
| sort | uniq -c | sort -hr | head -10
done
@sudipidus
sudipidus / slack-me.py
Last active May 1, 2019 13:47
This is a simple python script to trigger a slack web hook. It can be triggerred by piping linux commands or by passing arguments. (Messages are delivered to the configured slack channel)
#!/usr/bin/python
import requests as r
import json
import sys
web_hook='' # slack web hook url
def send_message(msg):
payload={'text':msg}
one_man_army_hook=webhook
headers= {'Content-type': 'application/json'}
@sudipidus
sudipidus / filenameappender.sh
Created October 16, 2018 12:32
To append a serial number to all the files contained in a directory
files=$(ls | awk '{print $1}')
serial=1
for fn in $files; do
echo "the next file is $fn"
extension="${fn##*.}"
filename="${fn%.*}"
echo "serial is $serial"
echo "filename is $filename and extension is $extension"
newfilename=$filename$serial
echo "mv $filename.$extension $newfilename.$extension"
wget -r -P ./pdfs -A pdf /web_url_containing_links/
#!/bin/bash
server="$1"
lines=100
echo server is $server
if [ "$#" -eq 2 ]; then
lines="$2"
fi
echo lines are $lines
logfile=/root/logs/staging$server/logfile.log
echo Opening $logfile
@sudipidus
sudipidus / The Technical Interview Cheat Sheet.md
Created January 22, 2018 09:21 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.