Skip to content

Instantly share code, notes, and snippets.

View gpsarkar's full-sized avatar
💭
🚀

Ganapati Sarkar gpsarkar

💭
🚀
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / gist:19888bf7e042c707d25c64619829110e
Last active August 9, 2018 19:10
greasemonkey script for removing ads from a site
// ==UserScript==
// @name SanFoundaryRemoveAds
// @version 1
// @grant GM_util
// @match https://www.sanfoundry.com/*
// @author SRKR
// ==/UserScript==
// Styles function - needs to be added in GM 4
@gpsarkar
gpsarkar / JS-LINQ.js
Created July 22, 2018 14:23 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
Linear gradient on line
<svg xmlns="http://www.w3.org/2000/svg" version="1"> <defs> <linearGradient id="e" x1="40" y1="235" x2="40" y2="265" gradientUnits="userSpaceOnUse"> <stop stop-color="steelblue" offset="0" /> <stop stop-color="red" offset="1" /> </linearGradient> </defs> <line x1="40" y1="210" x2="460" y2="290" stroke="url(#e)" stroke-width="30"/> </svg>
@gpsarkar
gpsarkar / browser prefetch and performance.txt
Created June 17, 2018 20:16
browser prefetch and performance
Resolve DNS
<link rel="dns-prefetch" href="//example.com">
Resolve DNS and also make the TCP handshake and optional TLS negotiation
<link rel="preconnect" href="http://css-tricks.com">
Fetch and store in cache, Definitely for webfont
Note: The CSP report server should be on the same origin as the website, otherwise some browsers won't send the report. This can easily be achieved with a proxy. Here's an Nginx example:
location /csp-report {
rewrite ^(.*)$ / break; # Rewrite everything to just /
proxy_pass http://csp-report.herokuapp.com;
}
Ref: https://github.com/bu-ist/csp-report