This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
memtotal=$(free | grep Mem | awk '{ print $2 }') | |
memuse=$(free | grep Mem | awk '{ print $3 }') | |
let "memusepercent = $memuse * 100 / $memtotal " | |
let "memtolerance = $memtotal * 0.9 " | |
echo "MemTotal: $memtotal (Usage tolerance: $memtolerance )" | |
echo "MemUsed: $memuse ($memusepercent %)" | |
if [ $memuse -ge $memtolerance ]; then | |
echo "Memory use over 90%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
root /opt/www; | |
# Add index.php to the list if you are using PHP | |
index index.html index.htm index.nginx-debian.html; | |
server_name your_server www.your_server; | |
location / { | |
# First attempt to serve request as file, then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 8123 default_server; | |
listen [::]:8123 default_server; | |
server_name your_server; | |
add_header Strict-Transport-Security "max-age=31536000"; | |
access_log /var/log/nginx/some_app.access.log; | |
error_log /var/log/nginx/some_app.error.log; | |
location / { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Ionic", | |
"short_name": "Ionic", | |
"start_url": "index.html", | |
"display": "standalone", | |
"icons": [{ | |
"src": "assets/imgs/logo-512x512.png", | |
"sizes": "512x512", | |
"type": "image/png" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check out https://googlechromelabs.github.io/sw-toolbox/ for | |
* more info on how to use sw-toolbox to custom configure your service worker. | |
*/ | |
'use strict'; | |
importScripts('./bower_components/sw-toolbox/sw-toolbox.js'); | |
self.toolbox.options.cache = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Ionic App</title> | |
<base href="/" /> | |
<meta | |
name="viewport" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// ... | |
// Ref. https://developers.google.com/web/fundamentals/app-install-banners/ | |
function addToHomeScreen() { | |
let a2hsBtn = document.querySelector(".ad2hs-prompt"); // hide our user interface that shows our A2HS button | |
a2hsBtn.style.display = 'none'; // Show the prompt | |
deferredPrompt.prompt(); // Wait for the user to respond to the prompt | |
deferredPrompt.userChoice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Ionic App</title> | |
<base href="/" /> | |
<meta | |
name="viewport" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
//... | |
// Detects if device is on iOS | |
const isIos = () => { | |
const userAgent = window.navigator.userAgent.toLowerCase(); | |
return /iphone|ipad|ipod/.test( userAgent ); | |
} | |
// Detects if device is in standalone mode | |
const isInStandaloneMode = () => ('standalone' in window.navigator) && (window.navigator.standalone); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
//... | |
function showIosInstall() { | |
let iosPrompt = document.querySelector(".ios-prompt"); | |
iosPrompt.style.display = "block"; | |
iosPrompt.addEventListener("click", () => { | |
iosPrompt.style.display = "none"; | |
}); | |
} |