Skip to content

Instantly share code, notes, and snippets.

View byteshiva's full-sized avatar
🎯
Focusing

Siva byteshiva

🎯
Focusing
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<button>Click Me</button>
@byteshiva
byteshiva / destructuring.js
Created June 30, 2018 10:40 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
// Good
exports.sendEmail = functions.auth.user().onCreate(event => {
const mailgun = require('mailgun-js');
// ...
});
// Not As Awesome
const mailgun = require('mailgun-js');
exports.sendEmail = functions.auth.user().onCreate(event => {
// Client-side code, in my case a web browser
firebase.auth().onAuthStateChanged(function (user) {
this.user = user; // Set my local copy of the 'user' object
if (user) {
this.displayName = user.displayName;
this.photoURL = user.photoURL;
var userRef = firebase.database().ref('queues/login').child(user.uid);
userRef.remove()
.then(function () {
const function = require('firebase-functions');
functions.database.ref('queues/login/{uid}').onWrite(event => {
const config = functions.config();
// functions.config() returns your environment variables.
// In this case I have an array of my admin users' email addresses in accessControlLists.adminUsers
// It looks like ['[email protected]', '[email protected]']
const adminUsersString = config.['access-control-lists']['admin-users'];
const adminUsers = adminUsersString.split(',');
const user = event.data.val();
@byteshiva
byteshiva / gh-pages-deploy.md
Created June 11, 2018 16:49 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

# check for php syntax errors in changed files
git status|grep php| cut -d : -f 2 | xargs -n1 php -l
@byteshiva
byteshiva / Ansible-Vault how-to.md
Created April 25, 2018 16:28 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@byteshiva
byteshiva / index.js
Created April 4, 2018 15:46
TangibleMonthlyAstrophysics created by byteshiva - https://repl.it/@byteshiva/TangibleMonthlyAstrophysics
/*const {createLogger , format, transports } = require('winston');
const {combine, timestamp, label, prettyPrint} = format;
const logger = createLogger({
format: combine(
label({label: 'algo intro'}),
timestamp(),
prettyPrint()
),
transports : [new transports.Console()]

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets