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" | |
import "math/rand" | |
import "time" | |
import "bytes" | |
func main() { | |
rand.Seed(time.Now().Unix()) | |
fmt.Println(rand.Int()) |
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 ( | |
"flag" | |
"fmt" | |
"github.com/siddontang/ledisdb/client/go/ledis" | |
"math/rand" | |
"sync" | |
"time" | |
) |
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" | |
func f(p string) { | |
fmt.Println("function f parameter:", p) | |
} | |
func g(p string, q int) { | |
fmt.Println("function g parameters:", p, q) |
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
// +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"); |
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 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 |
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
#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: |
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
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'; |
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
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" |
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
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 |
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
# coding: utf-8 | |
class MyIterator(object): | |
def __init__(self, step): | |
self.step = step | |
def next(self): | |
if self.step == 0: | |
raise StopIteration | |