Skip to content

Instantly share code, notes, and snippets.

package main
import "fmt"
import "math/rand"
import "time"
import "bytes"
func main() {
rand.Seed(time.Now().Unix())
fmt.Println(rand.Int())
package main
import (
"flag"
"fmt"
"github.com/siddontang/ledisdb/client/go/ledis"
"math/rand"
"sync"
"time"
)
package main
import "fmt"
func f(p string) {
fmt.Println("function f parameter:", p)
}
func g(p string, q int) {
fmt.Println("function g parameters:", p, q)
// +build leveldb hyperleveldb
package main
// #cgo leveldb CFLAGS: -DLEVELDB=1
// #cgo hyperleveldb CFLAGS: -DHYPERLEVELDB=1
// #include <stdio.h>
// void pp() {
// #ifdef LEVELDB
// printf("hello leveldb \n");
#!/usr/bin/env bash
# Install BuildRequires from .spec file
function install_buildrequires()
{
requires=$(grep "BuildRequires" $1 | awk '{print $2}')
for require in $requires
do
echo "Installing $require"
yum install -y $require
#coding: utf-8
"""Pylogstat
Usage:
pylogstat.py parse FILE [--db DB] [--host HOST] [--port PORT] [--maxline MAXLINE]
pylogstat.py aggregate (--db DB) [--host HOST] [--port PORT] [--start
START] [--end END] [--delta DELTA]
pylogstat.py index (-c | -d) (--db DB) [--host HOST] [--port PORT]
Options:
@holys
holys / access.log
Last active January 4, 2016 02:09
python regular pattern for nginx access.log
14.145.146.20 - - [02/Dec/2013:00:01:01 +0800] "GET /api/groups HTTP/1.1" 200 28 "https://qing.wps.cn/" "qing-8.1.17.1 AppleWebKit(2.2.3)" "14.145.146.20" 0.002 -
----
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time';
filter {
# strip the syslog PRI part and create facility and severity fields.
# the original syslog message is saved in field %{syslog_raw_message}.
# the extracted PRI is available in the %{syslog_pri} field.
#
# You get %{syslog_facility_code} and %{syslog_severity_code} fields.
# You also get %{syslog_facility} and %{syslog_severity} fields if the
# use_labels option is set True (the default) on syslog_pri filter.
grok {
type => "syslog-relay"
input {
file {
type => "nginx"
path => "/var/log/nginx/localhost.access.log"
format => 'plain'
}
}
# We need to tell the filters (grok, date) that we want to act on the nginx
# type otherwise it won't do anything
# coding: utf-8
class MyIterator(object):
def __init__(self, step):
self.step = step
def next(self):
if self.step == 0:
raise StopIteration