Skip to content

Instantly share code, notes, and snippets.

nikhilwanpal nikhilw

Block or report user

Report or block nikhilw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nikhilw
nikhilw / package-amazon-music.sh
Last active Mar 9, 2018
Create amazon prime music desktop player for Linux
View package-amazon-music.sh
# You need
# 1. nativefier installed, install it as: npm install -g nativefier
# 2. a logo for your app, download and place locally as logo.png
#! /bin/sh
nativefier --name "Amazon music" --inject ./user-agent-switch.js --icon ./logo.png https://music.amazon.in/
@nikhilw
nikhilw / toggleMicOneLiner.sh
Last active Jan 7, 2019
Toggle mic on-off on a Ubuntu / Linux Mint machine with a keyboard shortcut
View toggleMicOneLiner.sh
#! /bin/sh
# static icon, easier to set as a bash alias or directly use as a single command instead of creating a script file.
amixer set Capture toggle | gawk 'match($0, /Front Left.*\[(.*)\]/, a) {print a[1]}' | xargs notify-send --hint=int:transient:1 -i "audio-input-microphone" "Mic switched: $1"
@nikhilw
nikhilw / aws_load_config.sh
Last active Jan 5, 2018
This script loads aws cli profile configure as aws environment configuration
View aws_load_config.sh
#! /bin/sh
# aws cli works with both: environment variables and values configured with `aws configure`.
# If our own script come to use env variables, like in case where we need to guess the url of a ECR reposiroty,
# there is hardly any support to load the profile values into environment.
# This script does just that!
set -e
profile="default"
#echo $profile
@nikhilw
nikhilw / scrollCloudwatch.js
Last active Dec 26, 2017
Scroll AWS cloudwatch logs up, when search is not enough: a js script that runs scroll for given number of times
View scrollCloudwatch.js
function scrollLogUp(times, currVal) {
currVal = currVal || 0;
if (times > currVal) {
scrollLogUp.timer = setTimeout(function() {
document.getElementsByClassName("cwdb-log-viewer-table-body")[0].scrollTop = 0;
scrollLogUp(times, ++currVal);
}, 1000);
} else {
console.log("done..")
}
@nikhilw
nikhilw / commit-msg
Last active Oct 5, 2019
git commit hook using node to ensure commit message follows a convention
View commit-msg
#!/usr/bin/env node
// NOTES:
// 1. This is one of the two implementation, if you do not have 'node' installed, there is a 'scala' counterpart.
// 2. To use this file, place it in .git/hooks/ in your repository.
// 3. You can also use this script to along with 'husky' npm module.
var fs = require("fs");
console.log("INFO: Validating git commit message.......");
var msg = fs.readFileSync(process.argv[2] || process.env.GIT_PARAMS || process.env.HUSKY_GIT_PARAMS, "utf8").replace(/\n/g, " ").substr(0, 50);
@nikhilw
nikhilw / createJenkinsContainer.sh
Last active Oct 15, 2018
docker Jenkins reusable container
View createJenkinsContainer.sh
#! /bin/bash
# When running for first time, have empty directories; skip the setup by unchecking all plugins, etc.
# then shutdown jenkins, add old files and restart.
# If it fails, make sure the directory docker-volumes/jenkins and all its children are owned by same user, owner of the docker process.
# Or just chown -R on the jenkins directory.
docker run -it --name jenkins --network="permanet" --ip="172.30.0.6" \
-v /home/nikhil/.m2:/var/jenkins_home/.m2 \
-v /home/nikhil/.gradle:/var/jenkins_home/.gradle \
-v /home/nikhil/.npm:/var/jenkins_home/.npm \
@nikhilw
nikhilw / kill-mysql-connections.sh
Last active Mar 3, 2017
Kill all open connections to a mysql server
View kill-mysql-connections.sh
#! /bin/bash
mysql -u root -proot -e "select id from information_schema.processlist;" | grep -e [0-9] | while read in; do mysql -u root -proot -e "kill $in"; done
echo "verify"
mysql -u root -proot -e "select count(id )from information_schema.processlist;"
View jq.plugin.asynceach.js
(function($, window, undefined) {
function AsyncEachHandler(arr, it, done) {
var defs = [];
$.each(arr, function(i, item) {
var def = new $.Deferred();
defs.push(def);
it(item, function(err) {
console.log("in here")
@nikhilw
nikhilw / parseAndLog.js
Created Aug 20, 2015
List all apps on a google play store page that are cheaper than a defined price
View parseAndLog.js
$(".display-price").each(function(i, app) {
if (parseInt($(app).text().replace(/Rs\.\s/gi, "")) < 50) {
var appDetails = $(app).parents(".details").find(".title");
if (appDetails.attr("title")) {
console.log(appDetails.attr("title") + ": https://play.google.com/" + appDetails.attr("href"))
// Or even: window.open()
}
}
});
@nikhilw
nikhilw / gist:b07c320e18160ee3d65f
Created Mar 12, 2015
List all event listeners on all elements in the currently loaded page.
View gist:b07c320e18160ee3d65f
jQuery("*").each(function(i, e) {var listeners = jQuery._data(e, "events"); if (listeners){console.log(e); console.log(listeners)}})
You can’t perform that action at this time.