View generateSasTokenUrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
BlobSASPermissions, generateBlobSASQueryParameters, StorageSharedKeyCredential, | |
} = require('@azure/storage-blob'); | |
/** | |
* Generate a secure token URL for a particular file in a storage account. | |
* | |
* @param {string} accountName The name of the storage account. | |
* @param {string} accountKey The account key. | |
* @param {string} container The container. |
View enum_in_javascript.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Season enums can be grouped as static members of a class | |
class Season { | |
// Create new instances of the same class as static attributes | |
static Summer = new Season("summer") | |
static Autumn = new Season("autumn") | |
static Winter = new Season("winter") | |
static Spring = new Season("spring") | |
constructor(name) { | |
this.name = name |
View clonetest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cloneObject(obj: any): any { | |
switch (obj["constructor"]) { | |
case Date: return new Date(obj); | |
case Object: return Object.keys(obj).reduce<{ [key: string]: any }>((newObj, key) => (newObj[key] = cloneObject(obj[key]), newObj), {}); | |
case Array: return obj.map(cloneObject); | |
} | |
return obj; | |
} | |
// Test |
View Solarin.bgptheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a custom theme template for gitprompt.sh and is used here: https://github.com/magicmonty/bash-git-prompt | |
# Install this package using: brew install bash-git-prompt | |
# Copy this file to $(brew --prefix)/opt/bash-git-prompt/share/themes/ | |
# Add the following code to your ~/.bash_profile | |
# if [ -f "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" ]; then | |
# __GIT_PROMPT_DIR=$(brew --prefix)/opt/bash-git-prompt/share | |
# GIT_PROMPT_ONLY_IN_REPO=1 | |
# GIT_PROMPT_THEME=Solarin | |
# source "$(brew --prefix)/opt/bash-git-prompt/share/gitprompt.sh" | |
# fi |
View bash-async.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mycommand & | |
child_pid=$! | |
while kill -0 $child_pid >/dev/null 2>&1; do | |
echo "Child process is still running" | |
sleep 1 | |
done |
View processMessages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ServiceBusClient } = require('@azure/service-bus'); | |
const moment = require('moment'); | |
const connectionString = process.env.SB_CONNECTION; | |
const queueName = process.env.SB_QUEUE_NAME; | |
/** | |
* Processing messages from service bus queue. | |
* | |
* @param {object} context The context. |
View sendMessages.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ServiceBusClient } = require('@azure/service-bus'); | |
const moment = require('moment'); | |
const connectionString = process.env.SB_CONNECTION; | |
const queueName = process.env.SB_QUEUE_NAME; | |
const listOfScientists = [ | |
{ | |
id: 1, | |
name: "Einstein", |
View scheduleEvent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Designed for Azure functions | |
module.exports = function (context, req) { | |
context.log('JavaScript HTTP trigger function processed a request.'); | |
const scheduledEvents = []; | |
//Add all scheduled events into an array | |
req.body.forEach(function (calendar) { | |
calendar.items.forEach(function (items) { | |
scheduledEvents.push({ | |
start: new Date(items['start']).toLocaleTimeString('en-US', { hour12: false }), |
View .eslintrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"extends": "google", | |
"plugins": [], | |
"parserOptions": { | |
"ecmaVersion": 6, | |
"sourceType": "module" | |
}, | |
"settings": { | |
"import/core-modules": [ | |
"aws-sdk" |
View vindecoder.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* VIN decoder. | |
* | |
* kevinboutin on 3/11/18. | |
* | |
* My VIN for testing is WBA3A5G59DNP26082 so use the following command to invoke: | |
* node vindecoder WBA3A5G59DNP26082 | |
* | |
* Examples: | |
* KM8JM12D56U303366 |
NewerOlder