Skip to content

Instantly share code, notes, and snippets.

View motss's full-sized avatar
🥑
Life is like a prototype, just like JavaScript. So, keep betting on JavaScript!

The web walker motss

🥑
Life is like a prototype, just like JavaScript. So, keep betting on JavaScript!
View GitHub Profile
@motss
motss / google-cloud-cmd.js
Created September 6, 2016 07:33
Google Cloud commands
// To init.
gcloud init
// To list all the compute instances.
gcloud compute instances list
// gcloud compute instances list | grep <instance_name>
// To ssh the instance.
gcloud compute ssh <machine_name>@<instance_name>
@motss
motss / find-custom-element-on-document.js
Last active January 16, 2017 15:26
Simple script to find custom elements on a page
var foundCustomElements = [];
var foundCustomElementNames = [];
// main function to deeply find all custom elements on a page.
function getAllCustomElements(nodes) {
nodes.forEach(el => {
if (el.shadowRoot) getAllCustomElements(node.shadowRoot.querySelectorAll('*'));
if (el.localName.includes('-') || el.getAttribute('is') && el.getAttribute('is').includes('-')) {
foundCustomElements.push(el);
@motss
motss / browser-support-for-Github.md
Last active July 23, 2019 05:01
Browser Support in Markdown for Github

Microsoft Windows x64

| Internet Explorer | Microsoft Edge | Mozilla Firefox |

@motss
motss / browser-support-for-bitbucket.md
Created September 14, 2016 02:20
Browser Support Markdown for Bitbucket (no HTML support)

| Internet Explorer Internet Explorer | Microsoft Edge Microsoft Edge | Mozilla Firefox Mozilla Firefox Developer Edition Mozilla Firefox | Google Chrome Google Chrome Dev Google Chrome Canary Google Chrome | Opera ![O

@motss
motss / find-remove-files-directories.js
Created September 15, 2016 17:42
Find and remove files and directories
// http://superuser.com/questions/602385/find-and-delete-all-the-directories-named-test-in-linux
// find <directory_location> -name <regex_of_file_or_directory> -type <type> -exec <command>;
find . -name bower_components -type d -exec rm -rf {} \;
@motss
motss / export-vs-export-default-in-es2015.js
Last active February 27, 2017 18:23
export vs export default in ES2015
// ES2015 module's export.
// utility.js
function generateRandom() { return Math.random(); }
function sum(a, b) { return a + b; }
export { generateRandom, sum };
// ES2015 module's import with export.
import { generateRandom, sum, default as haha } from './utility';
import * as utils from './utility';
@motss
motss / randomWithRange.js
Created October 6, 2016 04:06
Generating random number with minNumber and maxNumber inclusive.
// Generate random number between 0 and <maxNumber> inclusive.
function randomWithRange(minNumber, maxNumber) {
var _minNumber = minNumber || 0;
var _maxNumber = (maxNumber || 1) * 10 + 1 - _minNumber;
var _random = _minNumber + Math.floor(Math.random() * _maxNumber) / 10;
return randomWithRange;
}
@motss
motss / setup-babun.md
Created October 29, 2016 15:39
Babun - your favorite Windows Shell
@motss
motss / encodeURIComponentForFirebase.js
Last active November 17, 2016 14:19
strict encodeURIComponent for Firebase
// Strict escaping symbols not accepting by Firebase.
// https://www.firebase.com/docs/web/guide/understanding-data.html#section-creating-references
// Data Limits - A child node's key cannot be longer than 768 bytes, nor deeper than 32 levels.
// It can include any unicode characters except for . $ # [ ] / and ASCII control characters 0-31 and 127.
function encodeURIComponentForFirebase(str) {
return encodeURIComponent(str).replace(/[\.\#\$\[\]]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
},
@motss
motss / play_and_reverse_using_<Element.animate>.js
Last active November 21, 2016 14:35
play and reverse using Element.animate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<base href="https://polygit2.appspot.com/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<script>