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 / 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 / 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 / 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 / check_disk_space.sh
Last active June 2, 2022 04:56
Disk Space monitoring
#!/bin/bash
LIMIT='90'
DIR='/'
MAILTO='[email protected]'
SUBJECT="MySite disk usage reached above $LIMIT%"
MAILX='mailx'
which $MAILX > /dev/null 2>&1
if ! [ $? -eq 0 ]
then
@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 / 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 / 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.
@rjdp
rjdp / s3.vcl
Created October 27, 2017 10:35 — forked from rezan/s3.vcl
Varnish AWS S3 Gateway VCL
#
# Varnish AWS S3 Gateway VCL
#
# Allows global read (GET, HEAD) and ACL protected writes (POST, PUT, DELETE).
# When writing, pass in Content-Type and Content-MD5, both are optional.
#
# Params:
#
# %BUCKET% - S3 bucket name, S3 host may be regional
# %ACCESS_ID% - IAM access ID for bucket
@rjdp
rjdp / rofi issue
Created August 25, 2017 01:01
Rofi Issue
rofi usage:
rofi [-options ...]
Command line only options:
-no-config Do not load configuration, use default values.
-v,-version Print the version number and exit.
-dmenu Start in dmenu mode.
-display [string] X server to contact.
${DISPLAY}
-h,-help This help message.