Skip to content

Instantly share code, notes, and snippets.

View tyagiakhilesh's full-sized avatar

Akhilesh Tyagi tyagiakhilesh

  • Bangalore, India
View GitHub Profile
@tyagiakhilesh
tyagiakhilesh / aws-creds.bash
Created September 11, 2023 09:19 — forked from ddgenome/aws-creds.bash
Fetch AWS STS keys and set environment variables
#!/bin/bash
# Fetch 24-hour AWS STS session token and set appropriate environment variables.
# See http://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html .
# You must have jq installed and in your PATH https://stedolan.github.io/jq/ .
# Add this function to your .bashrc or save it to a file and source that file from .bashrc .
# https://gist.github.com/ddgenome/f13f15dd01fb88538dd6fac8c7e73f8c
#
# usage: aws-creds MFA_TOKEN [OTHER_AWS_STS_GET-SESSION-TOKEN_OPTIONS...]
function aws-creds () {
local pkg=aws-creds

Some helpful guidelines for pull requests and code reviews

It's been often said that programming is part art, part science - that because lots of times there's no single, simple solution to a problem; or if there is, we might not know about it. There's also an infamous joke that if there are n developers in the room, then there are n+1 opinions on how things should be done. That being said, here are some guidelines that should prevent friction when submitting or reviewing code.

The most important thing

The code has to work. Unless you open a PR as a work in progress, the code should be built and tested on a device or emulator.

If you have touched the gradle build files and changed build setup, it's useful to test the whole build from scratch (clean build) and all of the types and flavours. If you have touched payments (logic or UI), you should test that it still works correctly, both in test and production builds. If you updated external libraries, test the pertaining features (e.g. if you

@tyagiakhilesh
tyagiakhilesh / fb_auth.java
Last active November 17, 2022 17:08
Get User details of FirebaseUser with an UID also contain example of getting custom token
public void testTopicSubscribeUnSubscribe() {
try (final InputStream inputStream = CloudDatabase.class.getClassLoader().getResourceAsStream(<service acc file>)) {
FirebaseOptions options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(inputStream))
.setServiceAccountId("<service account email id>")
.build();
FirebaseApp.initializeApp(options);
final UserRecord userRecord = FirebaseAuth.getInstance().getUser("1cf4b276125bf7743124a2");
final String phoneNumber = userRecord.getEmail().replace("@nobrokerhood.abcd", "");
String uid = "some-uid";
@tyagiakhilesh
tyagiakhilesh / klov-docker-compose.yml
Created January 17, 2022 08:37
Starup Klov with Mongo in Compose. (In whatever directory you shall launch compose command, it shall laydown db data there itself)
version: '2'
services:
mongo:
image: mongo:latest
container_name: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=user
- MONGO_INITDB_ROOT_PASSWORD=password
- MONGO_INITDB_DATABASE=klov
ports:
@tyagiakhilesh
tyagiakhilesh / post-mortem.md
Created October 21, 2020 11:13 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files)

2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

  1. * Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  2. Added fs.file-max = 70000 to /etc/sysctl.conf
@tyagiakhilesh
tyagiakhilesh / RequestAndResponseLoggingFilter.java
Last active September 13, 2020 14:19 — forked from int128/RequestAndResponseLoggingFilter.java
Spring Web filter for logging request and response
import lombok.val;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
import javax.servlet.FilterChain;
package com.doorapp.listener.persistence;
import com.doorapp.bean.es.DeviceUsage;
import com.doorapp.bean.es.IIndexable;
import com.doorapp.bean.es.Resident;
import com.doorapp.entity.Lead;
import com.doorapp.entity.PartyRelationship;
import com.doorapp.entity.Person;
import com.doorapp.entity.Services;
import com.doorapp.entity.Visit;
@tyagiakhilesh
tyagiakhilesh / sort_by_time_slow_logs.sh
Created July 30, 2020 12:28
Sorty Mysql Query Logs
grep -w 'Query_time' /var/log/mysql/mysql-slow.log | awk '{print $3}' | sort -n
@tyagiakhilesh
tyagiakhilesh / redis-cluster.md
Last active March 27, 2022 11:53
Redis Cluster

To Create a redis cluster with redis5:

  • Download source code.
  • Compile it. make
  • cd <working/dir>
  • mkdir 7003 7004 7005
  • cp <redis/root/src/redis-server 7003/
  • cp <redis/root/src/redis-server 7004/
  • cp <redis/root/src/redis-server 7005/
  • cp <redis/root/src/redis-conf 7003/
  • cp <redis/root/src/redis-conf 7004/

This is for centos8 This is source

General summary of steps

alter your partition table so sda2 ends at end of disk
reread the partition table (will require a reboot)
resize your LVM pv using pvresize