Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Glauber Ramos glauberramos

🏠
Working from home
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 / bad.js
Created Jul 11, 2012
Bad javascript code - Example for blog post
View bad.js
//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 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 animate-intro.css
-webkit-animation-name: intro-right;
-webkit-animation-duration: 0.5s;
-webkit-animation-iteration-count: once;
-webkit-animation-timing-function: ease-out;
-webkit-animation-delay: 0s;
-webkit-animation-fill-mode: both;
-webkit-animation-name: intro-left;
-webkit-animation-duration: 0.5s;
-webkit-animation-iteration-count: once;
View registrationExample.html
<span>
<p>
<label>
Address
</label>
<input type="text" id="address1" name="address1" value="" size="73">
</p>
<p>
<label>
You can’t perform that action at this time.