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 / gulpfile.babel.js
Last active August 21, 2016 17:22
Minify Polymer Elements (HTML, CSS and JS) with Gulp to make things fly!
'use strict';
// Process flow: gulp backup --> gulp build --> gulp revert (optional)
// Folder structure in order to make this works:
// |- my-element-icons.html // extracted icons, if any.
// |- my-element.theme.html // external CSS file.
// |- my-element.html // main html.
// '- my-element.js // load JS file externally.
const fs = require('fs');
const gulp = require('gulp');
@motss
motss / awesome-terminal-theme.js
Created August 22, 2016 05:48
To get awesome theme on terminal
// https://github.com/robbyrussell/oh-my-zsh
// https://github.com/wesbos/Cobalt2-iterm
@motss
motss / git-fetch-merge-upstream.js
Last active September 2, 2016 15:59
git-fetch-merge-upstream
// https://help.github.com/articles/configuring-a-remote-for-a-fork/
// https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches
// List current configured remote repo for your fork.
git remote -v
// Specify a new remote upstream repo.
git remote add upstream <GITHUB_REPO_URL>
// https://help.github.com/articles/syncing-a-fork/
@motss
motss / ce-v0_plus_sd-v0-demo.js
Created September 3, 2016 15:33
Custom Element v0 + Shadow DOM v0 demo
const a = document.createElement('div');
document.body.appendChild(a);
const b = document.createElement('template');
b.innerHTML = `
<style>
:host { display: block; box-sizing: border-box; }
.container { background-color: var(--fancy-bg, red);
@media (min-width: 768px) {
@motss
motss / trap-focus-within-modal-dialog.js
Created September 3, 2016 18:09
trap focus within modal dialog
_trapFocusWithinModal (ev, focusableNodes, callback) {
const _kc = ev.keyCode;
if (ev.type === 'keydown' && _kc === TAB_KEY) {
console.log('keyboard tab on:', ev.target, focusableNodes);
// Prevent default TAB operation.
ev.preventDefault();
const _maxAllowableFocusableNodesLength = focusableNodes.length - 1;
@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 / 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 / install-node-with-intl.js
Last active September 26, 2016 05:15
Install Node with Intl
brew install node --with-intl=full-icu --download-all
// To reinstall with all locales.
brew reinstall node --with-full-icu
@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;
}