Skip to content

Instantly share code, notes, and snippets.

View cstpraveen's full-sized avatar
💻
#Coding

Praveen Srinivasan cstpraveen

💻
#Coding
View GitHub Profile
@cstpraveen
cstpraveen / service-workers.md
Created May 12, 2023 09:37 — forked from mmazzarolo/service-workers.md
Service Workers Tips

Service Workers Tips

Reloading a service worker

Reloading a page won't update/remove the previous version of its service worker. To make sure you're using the latest version of your service worker, make sure to check the "Update on reload" toggle in the "Application" ⭢ "Service Workers" section of the Chrome DevTools.

Simulate a network condition

To simulate a network condition (e.g.: offline, 3g, etc...) in a service worker on Chrome, uncheck the "Update on reload" toggle.

@cstpraveen
cstpraveen / unregisterServiceWorkers.js
Created May 11, 2023 06:41 — forked from mrienstra/unregisterServiceWorkers.js
Unregister service workers, verbose
navigator.serviceWorker.getRegistrations().then(function (registrations) {
if (!registrations.length) {
console.log('No serviceWorker registrations found.')
return
}
for(let registration of registrations) {
registration.unregister().then(function (boolean) {
console.log(
(boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' +
(registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') +
# Repo: someuser/myframework
# Fork: superteam/myframework
# Track:
git clone https://github.com/superteam/myframework.git
cd myframework
git remote add upstream https://github.com/someuser/myframework.git
# Update:
git fetch upstream
@cstpraveen
cstpraveen / setcert.sh
Created March 3, 2023 08:53 — forked from landonf/setcert.sh
opendj certificate configuration
#!/bin/sh
args=`getopt p:c:t:o:a: $*`
if [ $? != 0 ]; then
echo 'Usage: ...'
exit 2
fi
set -- $args
for i; do
@cstpraveen
cstpraveen / server.py
Created July 19, 2022 15:36 — forked from chris-allan/server.py
Basic Flask-Security server with principals and MongoDB sessions
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.security import Security, MongoEngineUserDatastore, \
UserMixin, RoleMixin, login_required
from flask.ext.principal import Permission, RoleNeed
# Create app
app = Flask(__name__)
app.config['DEBUG'] = True
@cstpraveen
cstpraveen / rest-api-response-format.md
Created July 16, 2022 02:20 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices

Redis Cluster Setup with Docker Swarm

Setup

./redis.sh

Test

test the redis cluster

function interceptNetworkRequests(ee) {
const open = XMLHttpRequest.prototype.open;
const send = XMLHttpRequest.prototype.send;
const isRegularXHR = open.toString().indexOf('native code') !== -1;
// don't hijack if already hijacked - this will mess up with frameworks like Angular with zones
// we work if we load first there which we can.
if (isRegularXHR) {
@cstpraveen
cstpraveen / Dockerfile
Created October 28, 2020 10:24 — forked from ricog/Dockerfile
Docker wait for mysql to be ready and then load sql
FROM mysql:5.6
MAINTAINER Your Name <[email protected]>
COPY wait-for-mysql.sh /
CMD /wait-for-mysql.sh
@cstpraveen
cstpraveen / PromQL-docker-swarm-node-name.md
Created October 14, 2020 10:13 — forked from eeddaann/PromQL-docker-swarm-node-name.md
query in PromQL to get docker swarm node names instead of node id

PromQL

Prometheus is a time-series db, it's query language called PromQL.

Here are some analogies from SQL which may help to understand the basics of PromQL better:

  • metric ~ sql table
  • label ~ sql column

example:

  • Count how many containers running on each node: