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
[BEGIN] 2017/9/27 17:57:30 | |
cat test.log | |
HOSTNAME=cbd7d8772e27 | |
TERM=xterm |
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 | |
# 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", |
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
#!/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 |
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
#!/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 |
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 "net" | |
func echoServer(c net.Conn) { | |
for { | |
buf := make([]byte, 512) | |
nr, err := c.Read(buf) | |
if err != nil { | |
return |
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
#!/bin/sh | |
SOCKDIR="/var/lib/qemu/sockets" | |
HOSTNAME="$1" | |
if [ -z "$HOSTNAME" ] | |
then | |
echo "usage: $0 HOSTNAME" >&2 | |
exit 1 | |
fi |
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
#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 |
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
# | |
# 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 |
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
# 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 |
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
<?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) |