-
Create a new user on the system:
sudo adduser --system --group --shell /bin/bash --home /opt/sentry sentry
-
Create the virualenv and install the required packages:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
"path/filepath" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net" | |
"os/exec" | |
"github.com/k0kubun/pp" | |
) | |
func Hosts(cidr string) ([]string, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://[email protected]:2200$uri.git' name='go-import'></head></html>"; |
- 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
OlderNewer