Skip to content

Instantly share code, notes, and snippets.

View eiyaya's full-sized avatar

stephen zhen eiyaya

  • Beijing. China.
View GitHub Profile
#!/usr/bin/python
#
# This program is intended to be run via sudo, and does the following
# things:
#
# 1. Sets up a high-performance networking environment by tweaking
# various sysctl settings.
# 2. Runs either an interactive shell or a command line program.
# 3. Resets the environment back to what it was.
#!/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 / apr_md5_generator.c
Last active August 29, 2015 14:10
apache md5 password hash generator
#include <stdio.h>
#include "apr-1/apr_md5.h"
int main(int argc, const char *argv[])
{
if (argc != 3)
{
printf("%s\n", "usage: apr_md5_generator password salt");
return -1;
}
@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:
HTTP transfer protocols
=======================
Git supports two HTTP based transfer protocols. A "dumb" protocol
which requires only a standard HTTP server on the server end of the
connection, and a "smart" protocol which requires a Git aware CGI
(or server module). This document describes both protocols.
As a design feature smart clients can automatically upgrade "dumb"
protocol URLs to smart URLs. This permits all users to have the
@eiyaya
eiyaya / app.js
Last active August 29, 2015 14:25 — forked from fidelisrafael/app.js
Easy way to export data to XLS format using Node.js
// clone this gist to a empty folder, the run:
// npm init (and follow steps)
// npm install express --save
// npm install swig --save
// node app.js and open http://localhost:3000
function App() {
var express = require('express');
@eiyaya
eiyaya / gist:4154490
Created November 27, 2012 14:26
count svn diff
#/usr/bin/env python
diff="""
-
-
-
-
@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']