Skip to content

Instantly share code, notes, and snippets.

View anubhavsrivastava's full-sized avatar

Anubhav Srivastava anubhavsrivastava

View GitHub Profile
const resources = performance.getEntriesByType("resource").map(r => ({
type: r.initiatorType,
url: r.name,
}));
console.table(resources);
<script>document.location='https://d12tbd6xzgxi73.cloudfront.net/app/uploads/2024/10/IT-security-meme-8.jpg'</script>
for i in */; do zip -r "${i%/}.zip" "$i"; done
@anubhavsrivastava
anubhavsrivastava / Chrome
Created March 12, 2020 13:15
Disable web security to make CORS request
open -a Google\ Chrome\ Canary --args --disable-web-security
on its own does not work anymore. You need to use it with --user-data-dir:
open -a Google\ Chrome\ Canary --args --disable-web-security --user-data-dir=$HOME/profile-folder-name
http://stackoverflow.com/a/34680023/368691
@anubhavsrivastava
anubhavsrivastava / generate_releasenotes
Created December 27, 2019 14:28
bash script to generate release notes from github repo
#!/usr/bin/env bash
set -e
usage() {
echo "$0 <repo> <tag> [<release name>]" >&2;
}
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
@anubhavsrivastava
anubhavsrivastava / update_changelogs
Created December 27, 2019 14:27
Script to generate changelogs from Git Repo
#!/usr/bin/env bash
set -e
usage() {
echo "$0 <tag> <repo>" >&2;
}
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
function fixCurry(fn, totalArgs){
totalArgs = totalArgs ||fn.length
return function recursor(){
return arguments.length<fn.length?recursor.bind(this, ...arguments): fn.call(this, ...arguments);
}
}
var add = fixCurry((a,b,c)=>a+b+c);
console.log('Add')
function add(){
let args = [].slice.apply(arguments);
function resultFn(){
args = args.concat([].slice.apply(arguments));
if(args.length>=3){
return args.slice(0,3).reduce(function(acc,next){ return acc+next},0)
}
return resultFn
function add(x){
let sum = x;
return function resultFn(y){
if(arguments.length){ //not relying on falsy value
sum += y;
return resultFn;
}
return sum;
}
}
function add(x){
let sum = x;
return function resultFn(y){
sum +=y;
resultFn.result = sum;
return resultFn;
}
}