Skip to content

Instantly share code, notes, and snippets.

View eperedo's full-sized avatar
🎲
remote only

Eduardo Peredo Rivero eperedo

🎲
remote only
View GitHub Profile
@eperedo
eperedo / tutorial_pagination.js
Last active April 16, 2021 22:25
platzi tutorials pagination
// Open the developer tools in chrome/edge and run this code in any course page
// If the course only has 10 or less tutorials you are NOT going to see any change.
// Courses with more than 10 tutorials to test this script: https://platzi.com/clases/git-github/
// You will see the pagination at the bottom of the tutorials section
const tutorials = window.initialData?.initialState?.tutorials;
const courseId = window.initialData?.initialState?.course?.id;
const userId = window.contactInfo?.userId;
const avatarDom = document.querySelector('.Actionsv2-avatar');
let avatarUrl = '';
@eperedo
eperedo / invert.js
Last active April 6, 2021 00:55
Platzi light mode using invert 🙊
function styleDarkMode() {
var filterStyle = document.createElement('style');
filterStyle.innerHTML =
':root{filter: invert(100%);}img, video { filter: invert(100%);}.vjs-fullscreen {background-color: white !important;filter: invert(1) !important;}';
document.head.appendChild(filterStyle);
}
// run styleDarkMode() in a page that has the dark mode (using the developer tools).
// you can see a preview of how it looks here https://user-images.githubusercontent.com/461124/113607722-2ab34680-960f-11eb-80ff-70599a7081bc.png
// awful, right? But no more eye strain (at least for me)
@eperedo
eperedo / example.json
Created September 12, 2018 20:08
google place autocomplete example
{
"address_components": [
{
"long_name": "Avenida Arequipa",
"short_name": "Av. Arequipa",
"types": [
"route"
]
},
{
@eperedo
eperedo / questions.md
Created September 4, 2017 16:13
Ejercicio vue-resource
@eperedo
eperedo / about.vue
Created August 23, 2017 19:57
meta tags in single page application
<template>
<div>
About Page {{message}}
</div>
</template>
<script>
function metaInfo() {
return {
@eperedo
eperedo / about.vue
Created August 23, 2017 19:57
meta tags in single page application
<template>
<div>
About Page {{message}}
</div>
</template>
<script>
function metaInfo() {
return {
@eperedo
eperedo / fromObjectToQueryParams.js
Last active July 16, 2017 19:56
Convert object to query parameters
function objectToQuery(obj, notInclude = []){
const keys = Object.keys(obj);
const keysToConvert = keys.filter((kf) => {
return notInclude.indexOf(kf) === -1;
})
const qs = keysToConvert.map((key) => {
const currentKey = obj[key];
return `&${key}=${currentKey}`;
});
return qs.join('');
@eperedo
eperedo / transformArrayToObject.js
Last active June 15, 2017 19:28
Convert an array of json objects to an object. I KNOW!
var a = [{"id": 42, "name": "TALLA", "companyId": 40, "createdAt": "2017-02-13T21:51:15.000Z", "updatedAt": "2017-02-13T21:51:15.000Z", "flagActive": 1}, {"id": 37, "name": "TELA", "companyId": 40, "createdAt": "2017-02-13T21:23:11.000Z", "updatedAt": "2017-02-13T21:23:11.000Z", "flagActive": 1}, {"id": 38, "name": "TIPO DE PRENDA", "filterable": true}, {"id": 39, "name": "MODELO", "filterable": true}, {"id": 41, "name": "COLOR", "filterable": true}, {"id": 40, "name": "MANGA", "filterable": true}]
function transformArrayToObject(array) {
var b = {};
array.forEach((item, index) => {
var keys = Object.keys(item);
b[item.id] = {};
keys.forEach((key) => {
b[item.id][key] = item[key];
});
@eperedo
eperedo / refactor.MD
Last active June 15, 2017 22:07
Chut quiz javascriptero