Skip to content

Instantly share code, notes, and snippets.

View andyxning's full-sized avatar
:octocat:
I may be slow to respond.

Ning Xie andyxning

:octocat:
I may be slow to respond.
  • Beijing, China
View GitHub Profile
@fajrif
fajrif / gist:1265203
Created October 5, 2011 18:12
git clone specific tag
git clone <repo-address>
git tag -l
git checkout <tag-name>
git branch -D master
git checkout -b master
@andrewrcollins
andrewrcollins / trim.awk
Created January 11, 2012 04:22
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
@nuxlli
nuxlli / unix_socket_request.sh
Last active January 25, 2024 04:37
Examples of http request in unix domain socket with shell, using socat, netcat or curl
#!/bin/bash
# References
# http://www.computerhope.com/unix/nc.htm#03
# https://github.com/daniloegea/netcat
# http://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
# http://unix.stackexchange.com/questions/33924/write-inside-a-socket-open-by-another-process-in-linux/33982#33982
# http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
# http://www.dest-unreach.org/socat/
# http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")
@bketelsen
bketelsen / nsqadmin-service.json
Last active March 20, 2024 07:10
This gist represents all the manifests you'll need to run a redundant and fault-tolerant NSQ cluster on Kubernetes. NSQ Admin's http interface is available on port 14171 on any node. There's an issue with NSQ Admin if you're running more than one lookupd service, so I recommend running just one lookupd until I figure it out.
{
"id": "nsqadmin-http",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 14171,
"protocol": "TCP",
"selector": { "name": "nsqadmin" }
}
@afolarin
afolarin / docker-log-gist.md
Last active March 16, 2023 13:02
docker-logs
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
SIGABRT: abort
PC=0x5fb6c8
goroutine 308297 [syscall, 4433 minutes]:
syscall.Syscall6(0x3d, 0x10a0c, 0xc2084e3aec, 0x0, 0xc2084b86c0, 0x0, 0x0, 0xc208433400, 0x347, 0x3b7)
/usr/local/go/src/syscall/asm_linux_amd64.s:46 +0x5 fp=0xc2084e3a50 sp=0xc2084e3a48
syscall.wait4(0x10a0c, 0xc2084e3aec, 0x0, 0xc2084b86c0, 0x90, 0x0, 0x0)
/usr/local/go/src/syscall/zsyscall_linux_amd64.go:124 +0x79 fp=0xc2084e3ab0 sp=0xc2084e3a50
syscall.Wait4(0x10a0c, 0xc2084e3b34, 0x0, 0xc2084b86c0, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/syscall_linux.go:224 +0x60 fp=0xc2084e3af8 sp=0xc2084e3ab0
@ebenoist
ebenoist / consumer.go
Last active March 1, 2020 16:23
nsq consumer
package main
import (
"errors"
"log"
"os"
"os/signal"
"syscall"
"github.com/nsqio/go-nsq"