Skip to content

Instantly share code, notes, and snippets.

View eiyaya's full-sized avatar

stephen zhen eiyaya

  • Beijing. China.
View GitHub Profile
@eiyaya
eiyaya / timeout.rb
Created December 9, 2012 10:13 — forked from lpar/timeout.rb
Run a shell command in a separate thread, terminate it after a time limit, return its output
# Runs a specified shell command in a separate thread.
# If it exceeds the given timeout in seconds, kills it.
# Returns any output produced by the command (stdout or stderr) as a String.
# Uses Kernel.select to wait up to the tick length (in seconds) between
# checks on the command's status
#
# If you've got a cleaner way of doing this, I'd be interested to see it.
# If you think you can do it with Ruby's Timeout module, think again.
def run_with_timeout(command, timeout, tick)
output = ''
import json,sys,os
import urllib2
url = 'http://x.x.x.x/job/x.x.x.x/lastBuild/api/json'
try:
u = urllib2.urlopen(url).read()
except:
exit(100)
baseim = json.loads(u)
baseim_revision = baseim["changeSet"]['revisions'][0]['revision']
rem see http://commons.apache.org/daemon/procrun.html
set SERVICE_HOME=c:\hoge
%SERVICE_HOME%\service.exe //IS//Jenkins --DisplayName=Jenkins --StartPath=%SERVICE_HOME% --LogPath=%SERVICE_HOME%\logs --LogLevel=Debug --StdOutput=auto --StdError=auto --StartMode=Java --StopMode=Java --Jvm=auto ++JvmOptions=-jar ++JvmOptions=start.jar
#!/sbin/runscript
# GitLab init script for Gentoo Linux
# see https://github.com/gitlabhq/gitlabhq/blob/master/doc/installation.md
GITLAB_BASE=/home/gitlab/gitlab
GITLAB_USER=gitlab
depend() {
need net mysql redis
}
# Two ENV variables control the 'gem' command:
#
# GEM_HOME: the single path to a gem dir where gems are installed
# GEM_PATH: a standard PATH to gem dirs where gems are found
#
# A gem directory is a directory that holds gems. The 'gem' command will lay
# out and utilize the following structure:
#
# bin # installed bin scripts
# cache # .gem files ex: cache/gem_name.gem

Benchmarking Nginx with Go

Today I just wanted to know which of these options is faster:

  • Go HTTP standalone
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI

Hardware

@eiyaya
eiyaya / client.go
Created December 16, 2013 03:32 — forked from spikebike/client.go
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
import groovyx.net.http.*;
import static groovyx.net.http.ContentType.*;
import static groovyx.net.http.Method.*;
class NexusArtifactCleanup {
/**
* Settings in which to run script.
*/
@eiyaya
eiyaya / sshd.go
Last active August 29, 2015 14:12 — forked from jpillora/sshd.go
// A simple SSH server providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client: