Skip to content

Instantly share code, notes, and snippets.

Marcelo Ribeiro marcelo-ribeiro

Block or report user

Report or block marcelo-ribeiro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@marcelo-ribeiro
marcelo-ribeiro / capitalize.js
Last active Aug 14, 2019
Javascript String Capitalize
View capitalize.js
export const capitalize = value => {
if (!value) return "";
const list = value.toString().trim().split(" ");
list.forEach((item, index) => {
list[index] = item[0].toUpperCase() + item.slice(1).toLowerCase();
});
return list.join(" ");
@marcelo-ribeiro
marcelo-ribeiro / init-mdc-button-ripple.js
Last active Jul 5, 2019
Attach mdc ripple in all mdc buttons
View init-mdc-button-ripple.js
document
.querySelectorAll(".mdc-button")
.forEach(button => new mdc.ripple.MDCRipple(button));
@marcelo-ribeiro
marcelo-ribeiro / gh-pages-deploy.md
Created Jun 26, 2019 — 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).
View gh-pages-deploy.md

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).

@marcelo-ribeiro
marcelo-ribeiro / vscode-format-settings.json
Last active Jul 17, 2019
Typescript and CSS Format Pattern - CSS: Install CSScomb extension
View vscode-format-settings.json
{
"workbench.colorTheme": "Material Theme Ocean High Contrast",
"workbench.iconTheme": "material-icon-theme",
"editor.fontFamily": "Fira Code",
"editor.lineHeight": 24,
"editor.fontSize": 12,
"editor.fontLigatures": true,
"explorer.decorations.badges": false,
"editor.tabSize": 2,
"editor.autoClosingBrackets": "always",
@marcelo-ribeiro
marcelo-ribeiro / example-extend-defaults.js
Last active Oct 18, 2018
Polyfill js to extend objects and child objects
View example-extend-defaults.js
var defaults = {
firstName = 'John',
lastName = 'Doe'
};
var options = {
firstName = 'Jane'
};
extendDefaults(defaults, options);
@marcelo-ribeiro
marcelo-ribeiro / trim-all.js
Last active Sep 3, 2018
Trim All White Spaces
View trim-all.js
(function () {
if (!String.prototype.trimAll) {
String.prototype.trimAll = function () {
return this.replace(/\s+/g, '');
};
}
})();
// Example
console.log(' Hello World '.trimAll());
View vscode-settings.json
{
"workbench.colorTheme": "Material Theme Palenight High Contrast",
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.lineHeight": 26,
"editor.fontWeight": "500",
"editor.fontFamily": "Fira Code, monospace",
"editor.fontLigatures": true,
"terminal.integrated.lineHeight": 1.5,
"terminal.integrated.fontSize": 14,
@marcelo-ribeiro
marcelo-ribeiro / _variables-ease.scss
Created Mar 15, 2018
Material Design Ease Timing Functions Variables
View _variables-ease.scss
// TIMING FUNCTIONS
$ease: cubic-bezier(0.4, 0, 0.2, 1);
$ease-in: cubic-bezier(0.4, 0.0, 1, 1);
$ease-out: cubic-bezier(0.0, 0.0, 0.2, 1);
$ease-in-out: cubic-bezier(0.4, 0.0, 0.6, 1);
@marcelo-ribeiro
marcelo-ribeiro / loadMyAjax.js
Last active Jun 19, 2018
Javascript Ajax Cross-browser - Method POST
View loadMyAjax.js
var postsList = document.querySelector('.posts_list');
var paged = 1;
var countPosts = postsList.dataset.countPosts;
var postsPerPage = parseInt(postsList.dataset.postsPerPage);
window.addEventListener( 'onInfinite', getPosts );
function hasMoreItens() {
return postsList.children.length < countPosts;
}
@marcelo-ribeiro
marcelo-ribeiro / defaults-overrides.js
Last active Mar 2, 2018
ES6 defaults / overrides pattern
View defaults-overrides.js
var defaults = {
bar: 'no',
baz: 'works!'
};
function foo( options ) {
Object.assign( defaults, options );
console.log( defaults );
}
You can’t perform that action at this time.