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 / README.md
Created October 24, 2016 12:08 — forked from julianxhokaxhiu/README.md
How to install OSX 10.11 El Capitan on VMWare

How to install OSX 10.11 El Capitan on VMWare

To accomplish this tutorial you already need a previous copy of OSX installed on VMWare Player or Workstation.

0) Acquire a copy of OSX 10.11 El Capitan

First of all you need to acquire a legal copy of OSX El Capitan from the App Store. This tutorial will not cover this part. Sorry :)

1) Unlock OSX option on VMWare

Download the latest version of VMWare Unlocker and use the relative binary to unlock it ( based on your Host OS ).

@Jimmy-Xu
Jimmy-Xu / Install-SysinternalsSuiteNano.ps1
Created November 25, 2016 06:22 — forked from janegilring/Install-SysinternalsSuiteNano.ps1
This script will download the Nano Server version of the Sysinternals Suite and extract it to the specified target directory.
#requires -Version 5
<#
NAME: Install-SysinternalsSuiteNano.ps1
AUTHOR: Jan Egil Ring (@JanEgilRing)
COMMENT: This script will download the Nano Server version of the Sysinternals Suite and extract it to the specified target directory.
@Jimmy-Xu
Jimmy-Xu / github-proxy-ssh-tunnel-howto.md
Created January 11, 2017 13:05 — forked from Kagami/github-proxy-ssh-tunnel-howto.md
Using github through SSH tunnel
# Prerequisites: netcat-openbsd (BSD version of netcat)
$ ssh -fND 127.0.0.1:8081 user@<your-vps>
$ git config --global url."https://github".insteadOf git://github
$ git config --global http.proxy 'socks5://127.0.0.1:8081'
$ echo -e 'Host github.com\nProxyCommand nc -x 127.0.0.1:8081 %h %p' >> ~/.ssh/config

Alternative solutions:

@Jimmy-Xu
Jimmy-Xu / mb_substr_replace.php
Created January 19, 2017 05:18 — forked from stemar/mb_substr_replace.php
Multibyte substr_replace(). The mbstring library doesn’t come with a multibyte equivalent of substr_replace(). This function behaves exactly like substr_replace() even when the arguments are arrays.
<?php
function mb_substr_replace($string, $replacement, $start, $length=NULL) {
if (is_array($string)) {
$num = count($string);
// $replacement
$replacement = is_array($replacement) ? array_slice($replacement, 0, $num) : array_pad(array($replacement), $num, $replacement);
// $start
if (is_array($start)) {
$start = array_slice($start, 0, $num);
foreach ($start as $key => $value)
@Jimmy-Xu
Jimmy-Xu / windows10qemu.sh
Created February 8, 2017 13:49 — forked from Manouchehri/windows10qemu.sh
Running Windows 10 in a UEFI enabled QEMU environment with KVM.
# Installing
qemu-system-x86_64 -bios /usr/share/ovmf/ovmf_x64.bin -enable-kvm -cpu host -smp 4 -m 2048 -cdrom ~/Downloads/Win10_English_x64.iso -net nic,model=virtio -net user -drive file=~/vm/win10.hd.img.raw,format=raw,if=virtio -vga qxl -drive file=~/Downloads/virtio-win-0.1.105.iso,index=1,media=cdrom
# Running
qemu-system-x86_64 -bios /usr/share/ovmf/ovmf_x64.bin -enable-kvm -cpu host -smp 4 -m 4096 -net nic,model=virtio -net user -drive file=~/vm/win10.hd.img.raw,format=raw,if=virtio -vga qxl -usbdevice tablet -rtc base=utc
@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 / 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