Skip to content

Instantly share code, notes, and snippets.

View glauberramos's full-sized avatar

Glauber Ramos glauberramos

View GitHub Profile
@glauberramos
glauberramos / videoSpeed.js
Created June 22, 2021 20:44
Update video speed
document.querySelector('video').playbackRate = 1.5
'use strict'
require('firebase-functions/lib/logger/compat')
const functions = require('firebase-functions')
const admin = require('firebase-admin')
const express = require('express')
const cookieParser = require('cookie-parser')
const cors = require('cors')
try {
@glauberramos
glauberramos / bad.js
Created July 11, 2012 02:24
Bad javascript code - Example for blog post
//this function represents a book from an online library
//it has 3 methods to search the book, remove a specific word and change it
//it has 4 attributes, name, author, date and content
//creates libaries stuffz
function elementliBRaryContent(a,b,c,d) {
var bnam = a;var baut = b;
var bdat = c;
var bcont = d;
var self = { findword: function(x) { return bcont.indexOf(x)>=0;},
@glauberramos
glauberramos / index.html
Created October 10, 2017 03:29
Register service worker
<script>
if (navigator.serviceWorker) {
navigator.serviceWorker.register('./sw.js')
.catch(function(err) {
console.error('Unable to register service worker.', err);
});
}
</script>
@glauberramos
glauberramos / sw.js
Created October 10, 2017 03:20
Runtime caching using workbox
workboxSW.router.registerRoute('https://cdnjs.cloudflare.com/(.*)', workboxSW.strategies.staleWhileRevalidate({}), 'GET');
workboxSW.router.registerRoute('https://res.cloudinary.com/dc3dnmmpx/image/upload/(.*)', workboxSW.strategies.staleWhileRevalidate({}), 'GET');
workboxSW.router.registerRoute('https://unpkg.com/(.*)', workboxSW.strategies.staleWhileRevalidate({}), 'GET');
@glauberramos
glauberramos / main.ts
Created October 10, 2017 02:59
Imports on main.ts
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
CloudinaryModule.forRoot({Cloudinary}, { cloud_name: 'dc3dnmmpx' } as CloudinaryConfiguration)
],
declarations: [AppComponent],
bootstrap: [AppComponent],
@glauberramos
glauberramos / manifest.json
Created October 10, 2017 02:45
Manifest json example
{
"name": "Cloudinary PWA Angular",
"short_name": "Cloudinary PWA",
"lang": "en-US",
"start_url": "/",
"display": "standalone",
"theme_color": "#0e2f5a",
"background_color": "#0e2f5a",
"icons": [
{
@glauberramos
glauberramos / sw.js
Created October 10, 2017 02:36
Service worker application shell
importScripts('https://unpkg.com/workbox-sw@2.0.3/build/importScripts/workbox-sw.prod.v2.0.3.js');
const fileManifest = [
{
"url": "manifest.json",
"revision": "df8c1f88f48f4af912acb1e6a8053bfe"
},
{
"url": "cloudinary.png",
"revision": "df8c1f88f48f4af912acb1e6a8053bfe"
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e&&!isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}funct
@glauberramos
glauberramos / hideHeader.js
Last active December 24, 2015 14:36
Hide header
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('#menu').css('display', 'none');
} else {
$('#menu').css('display', 'block');
}
});