Skip to content

Instantly share code, notes, and snippets.

View gpsarkar's full-sized avatar
💭
🚀

Ganapati Sarkar gpsarkar

💭
🚀
View GitHub Profile
@gpsarkar
gpsarkar / linux diff script
Created August 16, 2018 20:28
linux diff script
#!/bin/bash
timestamp=`date "+%Y%m%d"`
source='/storage/source/'
target='/storage/target/'
exclude='folder'
diff --strip-trailing-cr --suppress-common-lines --ignore-case \
--ignore-tab-expansion --ignore-trailing-space --ignore-space-change \
--ignore-all-space --ignore-blank-lines \
@gpsarkar
gpsarkar / sfdry mcq practice - greasemonkey script
Created August 17, 2018 21:08
sfdry mcq practice - greasemonkey script
// ==UserScript==
// @name SanFoundaryPractice
// @version 1
// @grant GM_util
// @match https://www.sanfoundry.com/*
// @author SRKR
// ==/UserScript==
// Styles function - needs to be added in GM 4
@gpsarkar
gpsarkar / fiddler-capture-https-android-emulator
Last active May 10, 2022 06:18
fiddler capture https with android emulator
emulator -avd AndroidEmulator -partition-size 1024 -writable-system
Install toot certificate from `http://ipv4.fiddler:8888`
The certificate will now be located in /data/misc/user/0/cacerts-added/.
Remount /system R/W as root if you haven't already (mount -o remount,rw /system).
adb shell
@gpsarkar
gpsarkar / csp-report-uri-lambda.js
Created January 6, 2019 15:35
csp report uri lambda
const doc = require('dynamodb-doc');
const dynamo = new doc.DynamoDB();
const uuidv4 = require('uuid/v4');
exports.handler = (event, context, callback) => {
// Callback to finish response
const done = (err, res) => callback(null, {
statusCode: err ? '400' : '204',
body: err ? err.message : '',
@gpsarkar
gpsarkar / lambda-dynamo-db-iam-policy.yml
Last active January 6, 2019 15:39
lambda dynamo db iam policy
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:Create*",
"logs:Describe*",
"logs:Get*",
"logs:Put*"
],
@gpsarkar
gpsarkar / export-pfx-without-password.txt
Created March 4, 2019 14:23
export pfx without password
openssl pkcs12 -in MyCertificate.pfx -clcerts -nokeys -out MyCertificate.crt
openssl pkcs12 -in MyCertificate.pfx -nocerts -out MyCertificate-encrypted.key
openssl rsa -in MyCertificate-encrypted.key -out MyCertificate_unenc.key
openssl pkcs12 -export -out MyCertificate_np.pfx -inkey MyCertificate_unenc.key -in MyCertificate.crt -passout pass:
@gpsarkar
gpsarkar / openssl_commands.md
Created July 1, 2019 15:14 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@gpsarkar
gpsarkar / gist:5fdb9c52bca9b05aae9cc19f47c3dd5d
Created November 12, 2019 10:15
get userid and tenant id from access token using JwtSecurityTokenHandler
public static UserInfo GetClaimsFromToken(string accessTokenAsString)
{
var tokenHandler = new JwtSecurityTokenHandler();
if (!(tokenHandler.ReadToken(accessTokenAsString) is JwtSecurityToken accessToken)) return null;
var claims = accessToken.Claims.ToList();
var userId =claims.First(c => c.Type == "id").Value; // These could be different for your case
var tenantId = claims.First(c => c.Type == "tenant_id").Value;
return new UserInfo()
@gpsarkar
gpsarkar / gist:8e352d8de596d2f1e5a34344185602cc
Created February 4, 2020 12:26
Entity framework core migration command
Install nuget package "Microsoft.EntityFrameworkCore.Tools" in infrastructure project.
Run this in nuget console.
add-migration Initial -Context "XYZDbContext" -StartupProject ABC.XYZ.Web -Project ABC.XYZ.Infrastructure
@gpsarkar
gpsarkar / gist:4d8acb20f3f87561bc7b282472cf0b4e
Created February 17, 2020 19:51
Connec to postgres on host from docker
docker run --rm -it -p 5433:5433 --add-host=localhost:192.168.1.2 -p 80:80/tcp myimage:latest
C:\Program Files\PostgreSQL\11\data\pg_hba.conf
host all all 172.17.0.1/16 md5
host all all 192.168.1.2/32 md5
C:\Program Files\PostgreSQL\11\data\postgresql.conf
listen_addresses = '*'