Skip to content

Instantly share code, notes, and snippets.

View rsmoorthy's full-sized avatar

Moorthy RS rsmoorthy

View GitHub Profile
@rsmoorthy
rsmoorthy / README.md
Created February 3, 2015 21:28
sails-hook-extmodel: Sails.js hook for extending Models

fw Extended Models

This hook extends the models, its definition and its behaviour.

For now, various features will get added in this hook. And we will migrate them to proper ones, as we go by.

Extended enum support

This feature extends the values of enum from other sources. Other sources could be:

@rsmoorthy
rsmoorthy / match_ip.go
Last active November 3, 2015 18:18
Go: Match any interfaces/IP address for the corresponding CIDR provided
package main
import (
"net"
"fmt"
)
func matchCIDR(in_cidr string) (bool) {
_, in_net, err := net.ParseCIDR(in_cidr)
#!/usr/bin/env python
# This python script gets the cloudtrail logs and stores in /var/log/cloudtrail/
# cloudtrail.log. This fetches AND parses the following AWS logs and stores in files.
# a) CloudTrail logs (JSON gzipped)
# b) S3 Access Logs
# c) ELB Access Logs
# It can incrementally get only the new modified access logs (of any of the above) and append to existing files.
import boto3
@rsmoorthy
rsmoorthy / asynctimer.py
Last active October 7, 2018 08:49
Async Timer Example
import asyncio
class AsyncTimer:
def __init__(self, timeout, func, repeat=False, loop=None):
self.loop = loop
self._timeout = timeout
self._func = func
self._repeat = repeat
if loop:
self._task = loop.create_task(self._job())
@rsmoorthy
rsmoorthy / es541_cluster_allocation_explain
Last active October 12, 2018 19:33
ElasticSearch issues
# curl -XGET localhost:9200/_cluster/allocation/explain?pretty
{
"index" : "filebeat-2017.09.08",
"shard" : 0,
"primary" : true,
"current_state" : "unassigned",
"unassigned_info" : {
"reason" : "CLUSTER_RECOVERED",
"at" : "2018-10-12T19:09:07.740Z",
"last_allocation_status" : "no_valid_shard_copy"
@rsmoorthy
rsmoorthy / es640_fails_to_start
Created October 12, 2018 19:53
ES640 Fails to start
[2018-10-12T19:39:21,050][INFO ][o.e.n.Node ] [] initializing ...
[2018-10-12T19:39:21,111][INFO ][o.e.e.NodeEnvironment ] [5awoLm1] using [1] data paths, mounts [[/var/lib/elasticsearch (/dev/nvme1n1)]], net usable_space [229.1gb], net total_space [1.4tb], types [ext4]
[2018-10-12T19:39:21,111][INFO ][o.e.e.NodeEnvironment ] [5awoLm1] heap size [19.9gb], compressed ordinary object pointers [true]
[2018-10-12T19:39:22,670][INFO ][o.e.n.Node ] [5awoLm1] node name derived from node ID [5awoLm1yQ0yOkBdLy3FTzQ]; set [node.name] to override
[2018-10-12T19:39:22,670][INFO ][o.e.n.Node ] [5awoLm1] version[6.4.0], pid[95], build[default/tar/595516e/2018-08-17T23:18:47.308994Z], OS[Linux/3.10.0-862.11.6.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_181/25.181-b13]
[2018-10-12T19:39:22,670][INFO ][o.e.n.Node ] [5awoLm1] JVM arguments [-Xms20g, -Xmx20g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSIniti
@rsmoorthy
rsmoorthy / README.md
Last active October 3, 2022 18:29
Raspberry PI - Switch between Hotspot and Wifi modes