Skip to content

Instantly share code, notes, and snippets.

View srsajjad's full-sized avatar
🌱
Tinkering

Saidur Rahman srsajjad

🌱
Tinkering
View GitHub Profile
@srsajjad
srsajjad / index.html
Created November 14, 2018 09:26 — forked from jeffposnick/index.html
beforeinstallprompt demo
<html>
<head>
<title>Test</title>
<link rel="manifest" href="manifest.json">
</head>
<body>
<p>
If the <code>beforeinstallprompt</code> event fires, there will be a button displayed allowing
you to use <code>prompt()</code> on the deferred event.
</p>
@srsajjad
srsajjad / firebase-messaging-sw.js
Created November 6, 2018 18:50 — forked from loicginoux/firebase-messaging-sw.js
Adding FCM to an html page to receive notifications and sending then via FCM ruby gem
// [START initialize_firebase_in_sw]
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/3.5.2/firebase-messaging.js');
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
function getScrollDirection() {
let previous = window.scrollY
window.addEventListener('scroll', e => {
if(window.scrollY > previous){
console.log('going down')
}else{
console.log('going up')
}
previous = window.scrollY
})
function itObj(arr, value){
let nowIdx = -1
let itrObj = {
next(){
nowIdx += 1
if(nowIdx > arr.length - 1){
return {done: true}
}
@srsajjad
srsajjad / HistoryLocation.js
Last active August 28, 2018 07:23
Some Notes on History / Location Api
// window.location = '/foo' > pushes a new history entry > causes reload
// window.location = '/#foo' > does not push new history entry > does not cause reload
// window.history.pushState({name: 'Foo'}, 'foo', '/foo') > pushes a new history entry > does not cause reaload > has state object
// window.history.replaceState({name: 'Bar'}, 'bar', '/bar') > same as pushState but does not push a new history entry rather Overrides
@srsajjad
srsajjad / ImageLoad.js
Last active August 27, 2018 18:28
Some Notes On Image Upload On The Browser
// Blob to Canvas
// looks like we get Blob from FileReader API
// turn Blob into Canvas
// to do that we can use `blueimp-load-image` module/library
// look for the Exif orientation attribute to set it to `true`
// let's look at some related info -
let img = new Image()
@srsajjad
srsajjad / webdev_online_resources.md
Created July 17, 2018 04:59 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@srsajjad
srsajjad / ssh.txt
Created July 11, 2018 10:42 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets
# Login via SSH with password (LOCAL SERVER)
> ssh [email protected]
# Create folder, file, install Apache (Just messing around)
mkdir test
cd test
touch hello.txt
sudo apt-get install apache2
# Generate Keys
@srsajjad
srsajjad / sample.md
Created March 24, 2018 04:14 — forked from bradtraversy/sample.md
Markdown Cheat Sheet

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

This text is italic