Skip to content

Instantly share code, notes, and snippets.

View bvenkatr's full-sized avatar
🏠
Working from home

Venkat bvenkatr

🏠
Working from home
View GitHub Profile
#!/usr/bin/env bash
######################################################
#
# https://wiki.bash-hackers.org/howto/getopts_tutorial
# https://sookocheff.com/post/bash/parsing-bash-script-arguments-with-shopts/
######################################################
function help() {
echo -e "Project Initial Setup....\n"
echo -e "Usage: $0 COMMAND [PARAMETERS]..."
@bvenkatr
bvenkatr / post-merge
Created February 7, 2019 07:31 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
const {google} = require("googleapis");
const path = require("path");
// const {getCredentials} = require("./GoogleAuthenticator");
// Requiring json file is not working here, as google.auth.getClient accepts file path
// let keyFile = require("./google-service-account-credentials.json");
let keyFile = path.join(__dirname, "google-service-account-credentials.json");
// console.log(keyFile);
let scopes = [
'https://www.googleapis.com/auth/spreadsheets',
@bvenkatr
bvenkatr / transactions in loopback
Created August 3, 2017 04:58
testing a transaction with natvie sql query and built in ORM methods
'use strict';
let uuid = require("uuid");
/**
* 'use strict';
let uuid = require("uuid");
module.exports = function (Todos) {
Todos.testTransaction = function () {
Todos.beginTransaction(Todos.Transaction.READ_COMMITTED, function (err, tx) {
'use strict';
module.exports = function (Todos) {
Todos.validatesLengthOf('text', {min: 5, message: {min: 'text is too short'}});
//create a test remote method and do field validations using Validate object
Todos.saveTodosData = function (text, done, cb) {
setInterval(function() {
console.log("foo");
while (true) {
}
}, 1000);
setInterval(function() {
console.log("bar");
}, 1000);
@bvenkatr
bvenkatr / .babelrc
Created March 13, 2017 09:36 — forked from thejmazz/.babelrc
async/await with webpack+babel
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
@bvenkatr
bvenkatr / jsbin.yecewaj.js
Created February 25, 2017 06:51 — forked from nsisodiya/jsbin.yecewaj.js
Promise Based processing with Array. sequentialProcess and parallelProcess
//Author - Narendra Sisodiya - http://narendrasisodiya.com
//WHeN to use ? when async result from One Element is needed in another.
var sequentialProcess = function(arr, callback){
var pp = Promise.resolve();
arr.forEach(function(v, i, A){
pp = pp.then(function(){
return callback(v, i, A);
});