RSSAmplifier

Blog

Intro on Prithu Goswami

Recent content in Intro on Prithu Goswami

prithu.devRSS feed ↗47 posts

Latest posts

context engineering using links

I came across this interesting post . Some notes after reading it: Context engineering involves the process of activily making the context window work for the given task. Since LLMs have a bias to information close to the end of the context window, it’s important to optimize for this and remove all noise as the conversation progresses. Fresh invocations of LLMs with context perform better…

a2a protocol

https://a2a-protocol.org/latest/ It is primarily for agents to collaborate on long running tasks. A primary agent could leverage many agents to complete tasks. This is useful because the primary agent doesn’t have to polute it’s context with other tasks that can be handled in a seperate “thread”. The primary agent is responsible to steer the conversation with the secondary…

installing nixos on oracle cloud arm instance

Download netboot efi wget https://boot.netboot.xyz/ipxe/netboot.xyz-arm64.efi Move it to /boot/efi/ Open cloud shell connection from the instance page. On the instance page it’s labeled “Console Connection” under “Resources” “Reboot” the instance Continuously press Esc in the cloud shell. EFI boot manager pops up. Then open the EFI shell and type…

access cloudflare r2 using aws cli

Create R2 tokens from the r2 Overview page. &ldquo;Manage r2 API Tokens&rdquo; -> &ldquo;Create API Token&rdquo; Copy the access key id and secret access key values Copy the endpoint url. It&rsquo;s of the form <cloudflare_account_id>.r2.cloudflarestorage.com . Cloudflare account id is present in the url bar too when you are accessing the cloudflare dashboard and is also displayed in overview page…

python logging in aws lambda

LOG_LEVEL = os . getenv ( "LOG_LEVEL" , "INFO" ) . upper () logger = logging . getLogger () logger . setLevel ( level = LOG_LEVEL ) logger . info ( "Info log" ) logger . info ( "Error log" ) Also see amazon web services - Using python Logging with AWS Lambda - Stack Overflow

make lambda.zip using python poetry

poetry build poetry run pip install --upgrade -t dist/lambda dist/reporter*.whl cd dist/lambda; zip -r ../lambda.zip . -x '*.pyc'; cd ../../ If there are problems with some dependencies (GLIBC version mismatch) use --platform manylinux2014_x86_64 (or another type of linux pypi package) and --only-binary=:all: poetry run pip install --platform manylinux2014_x86_64 --only-binary=:all: -t dist/lambda…

https for local development

Use mkcert mkcert -install mkcert localhost # creates two localhost.pem (cert) and localhost-key.pem (key) file provide the key and cert file to the http server program. For example in python if using uvicorn: uvicorn.run("api.main:app", host="0.0.0.0", ssl_keyfile=key_path, ssl_certfile=cert_path, reload=True) Also read How to Create Your Own SSL Certificate Authority for Local HTTPS Development…

python module search path in aws lambda

When you use an import statement in your code, the Python runtime searches the directories in its search path until it finds the module or package. By default, the runtime searches the $LAMBDA_TASK_ROOT ( /var/task ) directory first. If you include a version of a runtime-included library in your image, your version will take precedence over the version that&rsquo;s included in the runtime. Other…

localhost not resolving for some programs

Check your /etc/hosts So ran into this stupid error where lnd was not starting because it was trying to lookup localhost and it couldn&rsquo;t resolve it so it asks the DNS server (1.1.1.1) and obviously can&rsquo;t resolve it either. failed to load config: lookup localhost on 1.1.1.1:53: no such host Add this to /etc/hosts 127.0.0.1 localhost

cloudfront proxied dns redirect loop issue

Faced an issue where I would get stuck in a redirect loop when configured a cloudflare dns as &lsquo;proxied&rsquo;. Turns out the solution is to set SSL/TLS mode to &lsquo;Full&rsquo; and that solves it. Ref https://community.cloudflare.com/t/enabling-cloudflare-dns-proxy-results-in-redirect-loop/510465

Debugging dwm to fix an annoying bug

I use dwm as my window manager and I always wanted to hack on it ever since I started using it and I have taken my first step towards that by debugging it and understanding the codebase a little. This post is just going to be a lot of snippets from dwm source code with my explanation on it as I understand it myself and sharing what I learnt while debugging dwm along the way. I wanted to fix an…

A bash gotcha - command substitution in bashrc

I have this alias in my bashrc: alias qn = "cd ~/docs/org/0-inbox/ && vim `date +%Y-%m-%d-%H%M`.md" which uses Command-Substitution 1 and basically just makes a &ldquo;quick note&rdquo; which I can refer later and move it a more appropriate place in my organized notes when I have the time. But when I run this alias it always opens the same note even if I run it at another time. TIL that using `…

useful git tidbits

--force-with-lease git push --force-with-lease &ndash; safer than just --force since if it doesn&rsquo;t expect the same commit before the force push to be there as yours, it doesn&rsquo;t push it. git maintenance start makes things faster. Does a bunch of stuff in the config that does automatic stuff in the background using systemd timers git blame -w -C -C -C much better than just git blame…

TIL: Cloudfront has a limit on URL length

Make sure that URL lengths are within range 8192 bytes Some other services might follow a generic 2000 character limit. http - What is the maximum length of a URL in different browsers? - Stack Overflow

Setting up wireguard VPN

Server Setup [Interface] PrivateKey = yMvNoQjJrhKBi9BM1GVDOgp12002CBsafprcucOLNXM= Address = 10.0.0.1/24 PostUp = iptables -A FORWARD -i wg1 -j ACCEPT; iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE PostDown = iptables -D FORWARD -i wg1 -j ACCEPT; iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE ListenPort = 52498 [Peer] PublicKey = VikFbA8ELVftC2Hzz7ukYCxTT229g2GxkwXmXMwqZhw= AllowedIPs…

TIL: AWS s3 folders

Although s3 has a flat structure—unlike a filesystem—it has a concept of &ldquo;folders&rdquo;. Folders are 0-byte objects whose key names end with a &lsquo;/&rsquo; When you create a folder from the s3 console it creates this object automatically and you can manually create it using cli with an object key ending in &lsquo;/&rsquo;…

using different python version with pyenv and poetry

install pyenv install a python version using pyenv install 3.9 this should have created a directory ~/.pyenv tell poetry to use a specific python version - poetry env use /home/prithu/.pyenv/versions/3.9.18/bin/python then run poetry install

good computer engineering videos

Software How to &ldquo;think&rdquo; (and design) like a Software Architect at Silicon Valley Code Camp 2019 Hardware The Future of Microprocessors — Sophie Wilson

docker tags with repo name must match the actual image

These are not the same docker tag api-service:latest 123456789012.dkr.ecr.eu-west-1.amazonaws.com/api:latest docker push 123456789012.dkr.ecr.eu-west-1.amazonaws.com/api:latest docker tag api-service:latest 123456789012.dkr.ecr.eu-west-1.amazonaws.com/api-service:latest docker push 123456789012.dkr.ecr.eu-west-1.amazonaws.com/api-service:latest Maybe this is obvious for future me. But this is the…

RPi server behind VPS using wireguard and iptables NAT

A few months ago, I wanted to host files stored on a portable hard disk on the public internet. These files were just some photos and videos that I wanted to share with some of my cousins. Nothing fancy, just a webdav server using rclone would suffice—a very ad-hoc setup as you can see. I wanted it to be reachable at share.prithu.dev to give it a short and friendly rememberable name. I used the…

example.com equivalent of IP addresses

The example.com equivalent of IP address is the block of 192.0.2.0/24. From rfc-3330 192.0.2.0/24 - This block is assigned as &ldquo;TEST-NET&rdquo; for use in documentation and example code. It is often used in conjunction with domain names example.com or example.net in vendor and protocol documentation. Addresses within this block should not appear on the public Internet.

API security

https://owasp.org/www-project-api-security/ https://www.youtube.com/playlist?list=PLbyncTkpno5HqX1h2MnV6Qt4wvTb8Mpol https://github.com/shieldfy/API-Security-Checklist https://github.com/OWASP/crAPI

programming books and articles

Working with Unix Processes Working with TCP Sockets Beej&rsquo;s Guide Use the Index Luke

CSRF Cookie

Complete this note with auth methods and how they are implemented are resources. https://security.stackexchange.com/questions/166724/should-i-use-csrf-protection-on-rest-api-endpoints

Actually good youtube channels

Computer Science Reducible - 3b1b type videos of CS topics Ben Eater - Computer architecture and electronics Computerphile - Computer science explained Zero To ASIC Course Science Nils Berglund - YouTube Makes cool simulations Infotainment Asianometry - YouTube Video essays on business, economics, and history. Sometimes about Asia, but not always.

packages, utils and tools

broot - A new way to see and navigate directory trees hstr - shell history suggest box - easily view, navigate, search and manage your command history. pasystray - A nice pulse audio system tray written in c GitHub - Canop/rhit: A nginx log explorer

noise generators

https://mynoise.net/ https://brainaural.com/ https://asoftmurmur.com/

the go programming language book notes

These are notes that I took while reading the The Go Prgogramming Language book Interesting points Go has some strictness when it comes to compiling if packages are imported but not used - don&rsquo;t compile if a newline is placed incorrectly - don&rsquo;t compile. Newlines follwing certain tokens are converted to semicolons automatically Semicolons are used only when statements are to be written…

Freedom of Monetary Transaction

Wrote the following in the FOSS United Telegram group, might expand this later as a blog post. Context Razorpay was put under scrutiny for accepting donation for a news org (altnews I believe?) from foreign sources. The discussion in the group was that whether or not it should have been allowed. I just chipped in. But, is it right to curb the inflow of money from foreign sources in some cases but…

AWS S3 access policy nuances

If you want to give access to everything in the bucket (objects) make sure the resource arn for the s3 bucket must also have a /* indicating all objects in the bucket "Resource": [ "arn:aws:s3:::BUCKET-NAME", ] This one won&rsquo;t give access to objects in the bucket, the following one will. "Resource": [ "arn:aws:s3:::BUCKET-NAME", "arn:aws:s3:::BUCKET-NAME/*" ] There is a difference between…

AWS Resource policies

There are two ways to manage access of a bucket - user policies or resources policies. Access policies that you attach to your resources (buckets and objects) are referred to as resource-based policies. You can also attach polcies to your users in your account, called user policies. Resources policies are attached to the resource (in s3 for eg. buckets or even objects). Resource policy dictates…

EKS vs ECS vs Fargate

tldr; ECS is just AWS&rsquo;s proprietary orchestration solution. EKS is their kubernetes service - you don&rsquo;t have to manage the kubernetes control plane (don&rsquo;t have access to master node, but you do get the kubernetes API). Fargate can be used with ECS or EKS and basically abstracts away the compute nodes on which containers run.…

using xxd to create binary data

xxd is a great tool. I have seen it be use in so many places. For some weird reason though it seems to come packaged with vim ?. Don&rsquo;t know about other distros, but that&rsquo;s the case with Arch. Seems like xxd was created by Bram and is a part of vim source code. Haven&rsquo;t looked into it further, but that&rsquo;s what I concluded. Anyways here&rsquo;s a small example: echo -en…

playwright is really good for browser automation

playwright is really good for browser automation. It is a re-write of puppeteer, I believe, and is maintained by the same devs and has tons of improvements, maybe because it was supported/sponsored by microsoft. It also has a wonderful feature of automatically recording your actions and converting them to a script. Running this would open a browser window and you can then record your actions. npx…

TIL: literal ipv6 in URLs

TIL from RFC2732 that the way you access an ipv6 address in a browser is by enclosing it in square brackets http://[2401:4900:f00b:dead:2f2d:48ac:9fdb:b7ff]:8080/path/file.txt

setting up cgit with nginx

server { server_name git.prithu.dev ; listen 80 ; access_log /var/log/nginx/git.prithu.dev/access.log ; error_log /var/log/nginx/git.prithu.dev/error.log ; #auth_basic "Git Login"; #auth_basic_user_file "/srv/git/.htpasswd"; location /static { alias /var/www/cgit ; try_files $uri = 404 ; } location / { fastcgi_pass unix:/run/fcgiwrap.socket ; fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi ;…

resources to learn about aws vpc

Videos Exploring the Fundamentals of AWS Networking (SVC211) AWS Networking Fundamentals Working with AWS Networking and Amazon VPC

nginx reverse proxy and url rewrite

Was just setting up shiori behind nginx and I wanted it such that https://prithu.dev/shiori passess the request to port 8001. I have been in this situation before as well where a path needs to be sent to a another host or application server. Just doing the following wont work: location /app { proxy_pass http://localhost:8001 ; proxy_set_header Host $host ; } nginx forwards the client request (…

keeping it simple dense and precise

I am going to try to keep this as dense and precise as possible and only store &ldquo;usefull&rdquo; knowledge. I am going keep this for things like &ldquo;how was I supposed to run a webdav server using rclone again&rdquo;; well maybe not that, because that&rsquo;s just a one line and belongs in the snippets.md file. But more like &ldquo;how do I setup weechat on android using an ssh tunnel and a…

Using server-side git hooks to auto publish blog posts

Git hooks are great to automate your software development workflow. They can be used to implement CI/CD workflows. Many PaaS services like Netlify and Heroku trigger a build process of your app or website when you push to a remote repository. In this post I want to go through how one could implement that automated process using git hooks for a static blog using just a bash script with nginx…

python one-liners using list composoition

TIL that there are really good ways of writing one-liners in python. I knew they existed but today I took a closer look at them. Most of the iterations can be done using list composition. You don&rsquo;t even have to be composing a list, you could be just executing a normal function call like in the example below uses &ldquo;print&rdquo; curl -s https://www.imdb.com/list/ls020046354/export |\…

reversing a firmware of security camera and squashfs

I saw a cool video by ghidra ninja on yt that went over firmware reversing for an a small security camera. He got the firmware from the site of the manufacturer and went over binwalk and showed how there&rsquo;s a linux filesystem on it in squashfs form. This was really amusing — the fact that there is a whole file system in a single binary. He then goes on to to see a rc script that runs on the…

dependency chain attack on magneto

There are hardware skimmers that collect card data when swiped but there can also be code written that can skim cards in an online checkout screen using code injection techniques. There was this incident where a group of hackers got access to a Magneto site and they modified a js library used in the checkout page and added a skimming code that would capture the card data entered in the forms of…

physical pen testers

I was listening to an episode of darknet diaries and learnt that there is this profession called a &ldquo;physical penetration tester&rdquo; where basically a person works for a institution who wants to test the security of their physical infrastructure (buildings). A client could be a bank or some other financial firm. The episode interviews two such people that worked for the security firm…

The beauty of Unix pipelines

View discussion on Hacker News The Unix philosophy lays emphasis on building software that is simple and extensible. Each piece of software must do one thing and do it well. And that software should be able to work with other programs through a common interface &ndash; a text stream. This is one of the core philosophies of Unix which makes it so powerful and intuitive to use. This is an excerpt…

The joys of using configurable programs like vim and i3

I see configurable software like vim and i3 really good tools to work with. I strongly believe you should have control over how something works in your toolset. Tools like vim and i3 allow for users to customize their workings in order fit their needs - this is what makes them so powerful and a joy to use. There are many instances where one feels the need to tweak their tools so that they could do…

Using jq to display cricket scores on i3bar

i3bar screenshot It&rsquo;s the IPL season and I thought why not keep a track of the score of the matches that are in progress. I have two tests tomorrow and I don&rsquo;t want to be wasting time looking at the scores every now and then; instead let&rsquo;s spend some more time looking into an utility that I haven&rsquo;t used before and test and play around with it. I don&rsquo;t even like…