Skip to content

Instantly share code, notes, and snippets.

@rjdp
rjdp / index.js
Created February 5, 2023 02:54
Sample express app with pprof endpoint instrumentation using Pyroscope
const express = require('express')
const app = express()
const port = 3002
const Pyroscope= require('@pyroscope/nodejs');
Pyroscope.init({ tags: { region: 'us-east-1' } })
app.use(Pyroscope.expressMiddleware())
@rjdp
rjdp / i3 commands
Last active January 12, 2023 19:36
list of useful i3 commands
reload i3 config - $mod + Shift + r
switch to vertical tiling - $mod + v
switch to horizontal tiling - $mod + h
switch to stack mode - $mod + s
switch to tiling mode - $mode + e
open dmenu(like ubuntu dash) - $mod + d
maximaize window - $mod + w
switch window in current workspace - $mod + <j|k|l|;> or <arrow key>
resize windows - $mod + r then press right/left arrow keys ; Esc to escape resize mode
switch window positon - $mod + shift + <left/right/up/down arrow>
@rjdp
rjdp / check_disk_space.sh
Last active June 2, 2022 04:56
Disk Space monitoring
#!/bin/bash
LIMIT='90'
DIR='/'
MAILTO='user@gmail.com'
SUBJECT="MySite disk usage reached above $LIMIT%"
MAILX='mailx'
which $MAILX > /dev/null 2>&1
if ! [ $? -eq 0 ]
then
@rjdp
rjdp / coursera_downloader.py
Last active December 22, 2020 16:49
Script for downloading course Lectures from coursera specialization or individual course
import os
import requests
import time
import sys
video_quality = "540p" # available qualities 360p, 540p, 720p
"""
In order to get courseId go to a course page open network tab in browser dev tools and search for "onDemandSpecializations"
in search input of network tab and then go to videos section of say week 1 , check the query param "courseId" its value is what we use can use as value for "one_of_specialization_course_id"
@rjdp
rjdp / error.log
Created November 25, 2020 23:28
wandb error logs
127.0.0.1 [RESPONSE] [23:21:49.055] [ Duration 388µs ↑ 77 B ↓ 258 B ]
127.0.0.1 404 Not Found
127.0.0.1 X-Amz-Request-Id: 164AE3A3A268354A
127.0.0.1 X-Xss-Protection: 1; mode=block
127.0.0.1 Accept-Ranges: bytes
127.0.0.1 Content-Length: 0
127.0.0.1 Content-Security-Policy: block-all-mixed-content
127.0.0.1 Server: MinIO/RELEASE.2020-02-27T00-23-05Z
127.0.0.1 Vary: Origin
127.0.0.1 X-Amz-Bucket-Region: wandb-local
@rjdp
rjdp / example.vcl
Created November 23, 2017 16:49
Fairly robust VCL for django sites, can be used with some changes depending on the web App
#
# This is an example VCL file for Varnish.
#
# It does not do anything by default, delegating control to the
# builtin VCL. The builtin VCL is called when there is no explicit
# return statement.
#
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
# and https://www.varnish-cache.org/trac/wiki/VCLExamples for more examples.
@rjdp
rjdp / default.vcl
Created February 4, 2017 00:02
Varnish 4.x vcl config for django
vcl 4.0;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
@rjdp
rjdp / count_cross.py
Last active June 16, 2018 15:59
Count number of times 2 things cross when moving in circular path
def count_cross(rph_a, rph_b, hours=1, pos_a=0, pos_b=0, opposite_dir=True):
import math
cross_count = 0
max_rounds = hours * max(rph_a, rph_b)
for i in range(int(math.ceil(max_rounds))):
round_fr = (max_rounds - i) if i == int(math.floor(max_rounds)) else 1
a_ahead = pos_a > pos_b if not pos_a == pos_b else "eq"
pos_a += (float(rph_a) / max(rph_a, rph_b)) * round_fr
pos_b += (float(rph_b) / max(rph_a, rph_b)) * round_fr
@rjdp
rjdp / update_schemas.sql
Created April 18, 2018 13:42
Loop over schemas in a Postgresql database and execute arbitrary DDL example
DO
$$
DECLARE
schemaname name;
BEGIN
FOR schemaname IN SELECT nspname FROM pg_namespace WHERE nspname LIKE 'schema_%' AND nspname <> 'information_schema' LOOP
RAISE NOTICE 'Running Alter on Schema : %', schemaname;
EXECUTE format('ALTER TABLE %I.common_commonconfigure ADD COLUMN google_secret_key varchar(150);', schemaname);
END LOOP;
END;
@rjdp
rjdp / irc.md
Created November 7, 2017 08:50 — forked from xero/irc.md
irc cheat sheet

#IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

##The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
    • Leaves the specified channel.