Skip to content

Instantly share code, notes, and snippets.

View anaynayak's full-sized avatar

Anay Nayak anaynayak

View GitHub Profile
@anaynayak
anaynayak / Log.hs
Last active June 23, 2020 14:04
LogMessage.hs
data MessageType = Info
| Warning
| Error Int
deriving (Show, Eq)
type TimeStamp = Int
data LogMessage = LogMessage MessageType TimeStamp String
| Unknown String
deriving (Show, Eq)
import sys
from PyQt5.QtWidgets import QSystemTrayIcon, QApplication
from PyQt5.QtGui import QIcon
class BuildNotifyTest:
def __init__(self, app):
self.app = app
self.tray = QSystemTrayIcon(QIcon.fromTheme("edit-undo"), self.app)
@anaynayak
anaynayak / xray-highlight.js
Last active May 16, 2018 17:14
Highlight nodes in X-ray
(function ($) {
var highlightEnvs = prompt('Highlight nodes containing(comma separated)', 'Prod,prd').split(',');
var hideEnvs = prompt('Hide nodes containing(comma separated)', 'dev,Dev,e2e,E2E').split(',');
highlightEnvs.forEach(function (env) {
$("g title:contains(" + env + ".)").parent().children('circle').css('fill', 'lightskyblue');
});
hideEnvs.forEach(function (env) {
$("g title:contains(" + env + ".)").parent().css('opacity', 0.5);
@anaynayak
anaynayak / dynamodb_cloudwatch_dashboard.js
Created May 14, 2018 13:24
Create Provisioned Capacity v/s Consumed Capacity dashboard in AWS Cloudwatch
var fs = require('fs'),
readline = require('readline');
var filePath = process.argv[2]
if (!filePath) {
console.error("node dynamo.js /path/to/file")
process.exit(1)
}
var rd = readline.createInterface({
input: fs.createReadStream(filePath),
console: false

Keybase proof

I hereby claim:

  • I am anaynayak on github.
  • I am anay (https://keybase.io/anay) on keybase.
  • I have a public key whose fingerprint is 555A A55F 2E91 306A 5EDD DEEA 9467 8869 A9A2 0850

To claim this, I am signing this object:

{
"sn": {
"title": "sn log format",
"description": "Log format",
"url": "http://lnav.readthedocs.io/en/latest/formats.html",
"regex": {
"basic": {
"pattern": "^\\[(?<timestamp>\\d{6} \\d{2}:\\d{2}:\\d{2}) ~ (?<level>\\w+)\\] \\[(?<status>\\d*) (?<verb>\\w*) \"(?<url>.*)\" .*?\\] (?<time>\\d*)ms \\((?<user>.*)\\) (?<detail>.*)$"
}
},
@anaynayak
anaynayak / fq
Last active November 5, 2015 16:37
#!/usr/bin/env python
import sys
import json
from collections import OrderedDict
opts = {
'format' : 'txt',
'keys' : sys.argv[1:]
}
#!/bin/sh
# /etc/init.d/tightvncserver
VNCUSER='pi'
case "$1" in
start)
su $VNCUSER -c '/usr/bin/tightvncserver :1'
echo "Starting TightVNC Server for $VNCUSER "
;;
stop)
pkill Xtightvnc
@anaynayak
anaynayak / recursive-git.zsh
Created February 24, 2014 05:03
A 'git' function that lets you recursively fire the same git command.
function git {
if [ -d .git ]; then
/usr/bin/git $*
else
for dir in $(find . -maxdepth 2 -name ".git"); do
cd ${dir%/*}
/usr/bin/git $*
cd -
done
fi
@anaynayak
anaynayak / url_requests.js
Created October 9, 2013 13:38
phantom.js script to log all http requests from a page
var page = require('webpage').create(),
system = require('system'),
address;
if (system.args.length === 1) {
console.log('Usage: phantomjs url_requests.js http://some.url.com');
phantom.exit(1);
} else {
address = system.args[1];
var logUrl = function (req) {