Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Glauber Ramos glauberramos

Block or report user

Report or block glauberramos

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
@glauberramos
glauberramos / index.html
Created Oct 10, 2017
Register service worker
View index.html
<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 Oct 10, 2017
Runtime caching using workbox
View sw.js
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 Oct 10, 2017
Imports on main.ts
View main.ts
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
CommonModule,
CloudinaryModule.forRoot({Cloudinary}, { cloud_name: 'dc3dnmmpx' } as CloudinaryConfiguration)
],
declarations: [AppComponent],
bootstrap: [AppComponent],
@glauberramos
glauberramos / manifest.json
Created Oct 10, 2017
Manifest json example
View manifest.json
{
"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 Oct 10, 2017
Service worker application shell
View sw.js
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"
View funny.js
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
View hideHeader.js
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('#menu').css('display', 'none');
} else {
$('#menu').css('display', 'block');
}
});
View ajaxNode.js
var http = require('http');
var server = http.createServer(function (request, response) {
function funcOne(input) {
var request = require('request');
request.get('http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/1930',
{json: true, body: input},
function(err, res, body) {
if (!err && res.statusCode === 200) {
console.log(err);
View api.js
$.ajax({
method: 'GET',
url: 'https://api.github.com/repos/servicosgovbr/cartas-de-servico/contents/cartas-servico/v3/servicos'
}).then(function(data) {
var servicos = data;
});
View gist:61da14a9e1face560927
setInterval([].forEach.bind($$("*"),function(a){a.style.outline="5px solid #"+(~~(Math.random()*(1<<24))).toString(16) }, 5), 10)
You can’t perform that action at this time.