Skip to content

Instantly share code, notes, and snippets.

View Jimmy-Xu's full-sized avatar

Jimmy Xu Jimmy-Xu

  • Ant Group
  • Beijing, China
View GitHub Profile
@Jimmy-Xu
Jimmy-Xu / nginx.conf
Created March 9, 2017 01:14 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@Jimmy-Xu
Jimmy-Xu / get-parent-process.psm1
Last active April 1, 2017 14:48
递归获取父进程
#usage:
# Import-Module ./get-parent-process.psm1 -Force
## example
# Get-ParentProcess -Name CExecSvc
# Get-ChildProcess -Name CExecSvc
function Get-ParentProcess {
[cmdletbinding()]
param(
[parameter(mandatory=$true,position=1)][string]$Name
@Jimmy-Xu
Jimmy-Xu / connect-qemu-serial.sh
Created April 5, 2017 08:22 — forked from nlm/connect-qemu-serial.sh
Connect to QEMU unix socket serial port
#!/bin/sh
SOCKDIR="/var/lib/qemu/sockets"
HOSTNAME="$1"
if [ -z "$HOSTNAME" ]
then
echo "usage: $0 HOSTNAME" >&2
exit 1
fi
package main
import "net"
func echoServer(c net.Conn) {
for {
buf := make([]byte, 512)
nr, err := c.Read(buf)
if err != nil {
return
@Jimmy-Xu
Jimmy-Xu / pxe-vm.sh
Created June 12, 2017 09:28 — forked from gdamjan/pxe-vm.sh
A script to start a qemu-kvm virtual machine that boots from PXE (it'll configure a bridge and add eth0 to it)
#!/bin/bash
MEM=1024
LAN=eth0
BRIDGE=virtbr
ARCH=x86_64 # i386
#BIOS="-bios OVMF.fd" # to emulate an UEFI netboot
# supported wifi interfaces can be bridged if you set 4addr mode first:
# iw dev $LAN set 4addr on
@Jimmy-Xu
Jimmy-Xu / setup-bridge.sh
Created June 29, 2017 09:23 — forked from ismell/setup-bridge.sh
Scripts to re-create the docker0 bridge and setup a different ip subnet
#!/bin/bash -e
IFADDR="192.168.3.1/24"
if [[ ! ip link show docker0 ]]; then
ip link add docker0 type bridge
ip addr add "$IFADDR" dev docker0
ip link set docker0 up
iptables -t nat -A POSTROUTING -s "$IFADDR" ! -d "$IFADDR" -j MASQUERADE
fi
@Jimmy-Xu
Jimmy-Xu / simple-exec-with-docker-remote-api.sh
Created September 7, 2017 13:35 — forked from markjlorenz/simple-exec-with-docker-remote-api.sh
Using the exec command with the docker API, and capturing output
#! /usr/bin/env bash
# Create the container with a long running process. If PID1 exists before
# we send the exec commands, they will fail because the container is not running
#
CONTAINER_NAME="TEST-`uuidgen`"
curl --silent --unix-socket /var/run/docker.sock "http:/containers/create?name=${CONTAINER_NAME}" -XPOST \
-H "Content-Type: application/json" \
-d '{
"Image": "ruby:latest",
@Jimmy-Xu
Jimmy-Xu / test.log
Created September 27, 2017 11:06
test.log
[BEGIN] 2017/9/27 17:57:30
cat test.log
HOSTNAME=cbd7d8772e27
TERM=xterm
@Jimmy-Xu
Jimmy-Xu / slack.sh
Created September 28, 2017 02:54
slack.sh
#!/bin/bash
TOKEN="$1"
CHANNEL_ID="$2"
MESSAGE="$3"
ATTACHMENT="$4"
NICK="HykinsBot"
EMOJI=":jenkins:"
curl -X POST \
-F token=$TOKEN \
@Jimmy-Xu
Jimmy-Xu / do_test_hyperd.sh
Last active October 10, 2017 08:02
do_test_hyperd.sh
#!/bin/bash
hack/test-cmd.sh
rlt=$?
#################
END_TS=`date '+%s'`
echo "Duration: $((END_TS - START_TS)) (seconds)"
###############################################