Tuesday, December 24, 2024
api load testing using locust
Friday, December 20, 2024
PIP install one by one package from requirements.txt
use below command:
cat requirements.txt | xargs -n 1 pip installPIP install one by one package from requirements.txt
Wednesday, December 11, 2024
How to remove sensitive data from Git repo
install git-filter-repo
brew install git-filter-repo
run command :git filter-repo --invert-paths --path PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA
git remote add origin https://github.com/OWNER/REPOSITORY.git
git push origin --force --all
Friday, December 6, 2024
AMPLIFY - Sample YAML file
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install --ignore-engines
build:
commands:
- yarn run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Monday, November 25, 2024
Alternative to ExpressJs - use Fastify
Fastify is faster framework for Node.js framework. It is way faster than express. Also has native async handler.
https://fastify.dev/
Thursday, July 25, 2024
Sunday, June 23, 2024
Complex aggregation queries Mongodb - Examples
Group and slice array
@Aggregation(pipeline = {
"{ $match: {'category':{$regex : ?0, $options: 'i'}}}",
"{ $group: { _id: {category:'$category'}, data: { $push: '$$ROOT' } } }",
"{ $project: { _id: 0, category:'$_id.category', videos:{ $slice:['$data',?1,?2]} }"
})
Sunday, June 9, 2024
Mongo playground - learn and tune query
Use MongoPlayground to learn and tune queries
https://mongoplayground.net/p/lhl5nqbRHta
Some examples:
1. Select max N of a group: (https://mongoplayground.net/p/h79lRA01Jop)
db.collection.aggregate([
{
"$match": {}
},
{
"$group": {
"_id": {
"name": "$name"
},
"data": {
"$push": "$$ROOT"
}
}
},
{
"$project": {
"_id": 0,
"name": "$_id.name",
"videos": {
"$slice": [
"$data",
2
]
}
}
}
])
Thursday, May 30, 2024
unable to connect to ubuntu after mac upgrade
use:
create .ssh/config
and write below content:
Host *
PubkeyAcceptedKeyTypes=+ssh-rsa
HostKeyAlgorithms=+ssh-rsa
Sunday, May 26, 2024
Template for spring boot - freemarker
checkout the docs at https://freemarker.apache.org/docs/dgui_misc_var.html
Saturday, April 6, 2024
unary operator in JS
+ operator before variable will always convert string to number
Friday, March 29, 2024
Express js EDGE template engine - how to display HTML with tags
Express js EDGE template engine - how to display HTML with tags
use triple {{{
Example
<div>{{{variable}}}</div>
Monday, March 25, 2024
SSH without host key verification
if you are getting error in ssh to any host due to key verification.
use flag:
ssh -o StrictHostKeyChecking=no yourHardenedHost.com
Tuesday, March 19, 2024
Saturday, March 16, 2024
Launching HireIntel as AI based hiring platform
Happy to announce that I am working on HireIntel. HireIntel is a AI based screening and interview platform. It uses AI to shortlist and recommend right candidates for a job. It sorts all eligible candidates using rank in AI interview conducted on the platform.
To get started: use https://hireintel.app
How to restore pm2 list
use pm2 resurrect
How to solve "Current process list is not synchronized with saved list"??
use pm2 resurrect
Thursday, February 8, 2024
MongoDB async queries
1. Install Motor
pip install motor
2. create async client
import motor.motor_asynciomconn=motor.motor_asyncio.AsyncIOMotorClient(getMongoConnectionString())
db=mconn.db_namecoll= db.coll_namefind query:mobjs = coll.find(..)async for obj in mobhsupdate callawait coll.update...wait for longawait asyncio.wait_for(queue.join(), timeout=None)
Saturday, February 3, 2024
Managing log files on ubuntu
1. use /var/log location
2. have logroate.d/ conf file
/var/log/gunicorn/*.log {
rotate 1
weekly
copytruncate
dateext
compress
missingok
notifempty
}
use copytruncate option
Wednesday, January 31, 2024
[PM2][WARN] Current process list is not synchronized with saved list.
How to solve: [PM2][WARN] Current process list is not synchronized with saved list.
pm2 update
pm2 startup
pm2 save
Monday, January 29, 2024
get timezone id from display name
import java.util.TimeZone;
public class TimeZoneExample {
public static void main(String[] args) {
// Set the desired time zone display name
String timeZoneDisplayName = "IST";
// Get the time zone ID based on the display name
String timeZoneID = getTimeZoneIDByDisplayName(timeZoneDisplayName);
if (timeZoneID != null) {
System.out.println("Time zone ID for " + timeZoneDisplayName + ": " + timeZoneID);
} else {
System.out.println("No matching time zone found for display name: " + timeZoneDisplayName);
}
}
private static String getTimeZoneIDByDisplayName(String displayName) {
String[] availableIDs = TimeZone.getAvailableIDs();
for (String id : availableIDs) {
TimeZone timeZone = TimeZone.getTimeZone(id);
if (displayName.equals(timeZone.getDisplayName())) {
return id;
}
}
return null; // Return null if no match is found
}
}
Monday, January 22, 2024
Sunday, January 7, 2024
configure BREW to not delete old versions on upgrade
set below environment variable
export
HOMEBREW_NO_INSTALL_CLEANUP=TRUE
JENV - Manage multiple Java environnments
1) install using brew
2) jenv add <JRE location>
3) jenv versions
4)jenv global <version name>
add below to .profile/.zshrc
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"