Skip to content

Instantly share code, notes, and snippets.

View RaviTezu's full-sized avatar
🎧
Wired In

RaviTeja Pothana RaviTezu

🎧
Wired In
View GitHub Profile
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) {
print("Killing opId: " + op.opid
@RaviTezu
RaviTezu / README.md
Last active August 29, 2015 14:14 — forked from jalaziz/README.md

Setup

  1. Create a new user on the system:

    sudo adduser --system --group --shell /bin/bash --home /opt/sentry sentry
  2. Create the virualenv and install the required packages:

@RaviTezu
RaviTezu / sentry
Last active August 29, 2015 14:14 — forked from thomas-p-wilson/sentry
#!/bin/bash
# /etc/init.d/sentry
# A debian-compatible sentry startup script
#
### BEGIN INIT INFO
# Provides: sentry
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@RaviTezu
RaviTezu / whisper-calculator.py
Last active September 10, 2015 10:36 — forked from jjmaestro/whisper-calculator.py
whisper-calculator.py: Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
@RaviTezu
RaviTezu / walk.go
Created November 13, 2015 10:40 — forked from tdegrunt/walk.go
Replace some text in a bunch of files with golang
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
@RaviTezu
RaviTezu / Install_nginx_from_src_with_module.sh
Last active November 26, 2015 10:11 — forked from zefer/Install_nginx_from_src_with_module.sh
Compile nginx from source, include the Headers More module - Ubuntu
sudo su -
# stuff we need to build from source
apt-get install libpcre3-dev build-essential libssl-dev
# get the nginx source
cd /opt/
wget http://nginx.org/download/nginx-0.8.54.tar.gz
tar -zxvf nginx*
# we'll put the source for nginx modules in here
@RaviTezu
RaviTezu / ipcalc.go
Created June 16, 2016 17:38 — forked from kotakanbe/ipcalc.go
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@RaviTezu
RaviTezu / go-get-gitlab-ssh-nginx
Created November 1, 2016 04:51 — forked from jpillora/go-get-gitlab-ssh-nginx
Go get Gitlab ssh paths with nginx
location / {
## check for goget AND /namespace/project
if ($args ~* "^go-get=1") {
set $condition goget;
}
if ($uri ~ ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$) {
set $condition "${condition}path";
}
if ($condition = gogetpath) {
return 200 "<!DOCTYPE html><html><head><meta content='git.axon$uri git ssh://git@gitlab.mycompany.com:2200$uri.git' name='go-import'></head></html>";
@RaviTezu
RaviTezu / stages.md
Created September 29, 2017 06:56 — forked from lestrrat/stages.md
Seven Stages of Becoming a Go Programmer
  • stage 1: You believe you can make Go do object oriented programming. You want to do this by using clever struct embedding.
  • stage 2: You believe goroutines will solve all of your problems. You want to use goroutines for anything and everything that you can, who cares if the code becomes a bit more complicated
  • stage 3: You believe that instead of object oriented programming, interfaces will solve all of your problems. You want to define everything in terms of interfaces
  • stage 4: You believe channels will solve all of your problems. You want to do everything from synchronization, returning values, and flow control using channels.
  • stage 5: You now believe Go is not as powerful as people claim it to be. You feel like you're stripped of all of the nice tools and constructs that other languages provide.
  • stage 6: You realize that stages 1~5 were all just your imagination. You just didn't want to accept the Go way. Everything starts to make sense.
  • stage 7: You are now at peace