Skip to content

Instantly share code, notes, and snippets.

@zymr-keshav
zymr-keshav / sw.js
Created August 1, 2017 12:12
Service Worker Example
'use strict';
let appCaches = [{
name: 'app',
urls: [
'/app/',
'/'
]
}, {
name: 'offline',
@zymr-keshav
zymr-keshav / timechart.js
Created August 14, 2017 06:43
create default 12 hours tiem data with difference of 1 hour
const getDatesRangeArray = function(startDate, endDate, unit, step) {
// console.log("getDatesRangeArray", arguments);
var interval = {
unit_: unit || 'hours',
step_: step || 1
},
dateArray = [],
currentDate = startDate;
// console.log("currentDate", currentDate);
while (currentDate <= endDate) {
@zymr-keshav
zymr-keshav / Prefrences.sublime-settings
Created August 29, 2017 10:10
Sublime text 3 Settings for mac os
{
"always_show_minimap_viewport": true,
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"caret_extra_bottom": 1,
"caret_extra_top": 1,
"caret_extra_width": 1,
"caret_style": "blink",
@zymr-keshav
zymr-keshav / _filter.controller.js
Last active August 31, 2017 19:15
useful angulr basic filters
(function() {
'use strict';
angular
.module('app')
.filter('STRING_LIMIT_FILTER', function() {
return function(input, num) {
let output = input.split(' ').slice(0, num).join(' ');
return output;
@zymr-keshav
zymr-keshav / servlet.sh
Last active September 10, 2017 10:44
create entry in mongodb using this script for monitoring data
#!/bin/bash
# call as `sh servlet.sh <node uuid> <node ip> <url> [servlet type]`
# exmaple sh servlet.sh 595e341fd7391071d21ce1b5 20.20.1.73 /servlet/acme/ CompareServer-0
header="Content-Type: application/json"
enc=$(gshuf -i 0-1000 -n 1) #generate random number (in unix use shuf , remove prefix g)
dec=$(gshuf -i 10-600 -n 1)
now=$(gdate +%s%3N) #generate current time in miliseconds ( in unix use date, remove prefix g )
uuid=$1 #first argument
ip=$2 #second argument
url_less=${3%/} #remove trailing slash, if any
@zymr-keshav
zymr-keshav / app.sh
Created September 10, 2017 10:48
curl using bash script with post data which have current time and random number
#!/bin/bash
# call as `sh app.sh -u <app uuid> -i <app ip> -t <url>`
# exmaple sh app.sh -u 595e341fd7391071d21ce1b5 -i 20.20.1.73 -t /monitor/application/acme/
# if you do not want to use - argument than comment while loop and uncomment commented uuid and ip
while getopts u:i:t: option
do
case "${option}"
in
u) uuid=${OPTARG};;
i) ip=${OPTARG};;
@zymr-keshav
zymr-keshav / .eslintrc
Created September 20, 2017 09:32
my eslint rc rule file in sublime-text3
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"angular": true,
"module": true,
@zymr-keshav
zymr-keshav / .jshintrc
Created September 20, 2017 09:32
jshintrc custom in sublime-text 3
{
"browser": true,
"esnext": true,
"node": true,
"immed": true,
"globals" : {
"moment": true,
"angular": true,
"saveAs": true,
"require": true
@zymr-keshav
zymr-keshav / .lesshintrc
Created September 20, 2017 09:33
custom lesshint rc file for ST3
{
"fileExtensions": [".less", ".css"],
"excludedFiles": ["vendor.less"],
"spaceAfterPropertyColon": {
"enabled": true,
"style": "one_space" // Comments are allowed
},
"singleLinePerSelector": false,
@zymr-keshav
zymr-keshav / .bash_profile
Created October 26, 2017 11:01
bash profile for mac OS X which have git branch name and colored terminal and useful alias
# git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"