Skip to content

Instantly share code, notes, and snippets.

View unakatsuo's full-sized avatar

Masahiro Fujiwara unakatsuo

View GitHub Profile
@unakatsuo
unakatsuo / menu.sh
Last active March 26, 2021 23:58
Run custom tui menu on tty1 with systemd getty.
#!/bin/bash
set -e
function show_main_menu() {
whiptail --nocancel --menu "Main Menu" 12 35 4 \
1 "Network Configuration" \
2 "Modify Hostname" \
3 "Factory Reset" \
3>&2 2>&1 1>&3
@unakatsuo
unakatsuo / iptc.go
Created April 11, 2018 13:22
libiptc with Go
package main
/*
#cgo pkg-config: libiptc xtables
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <xtables.h>
#include <libiptc/libiptc.h>
@unakatsuo
unakatsuo / nflog.go
Created April 6, 2018 13:06
nflog with Go
package main
import (
"log"
"os"
"unsafe"
)
/*
#cgo pkg-config: libnetfilter_log
@unakatsuo
unakatsuo / gist:f9ffdb1d8801c4c1214b5881f43f2b3c
Last active January 5, 2019 07:03
Clean old local docker images at once.
#!/bin/sh
docker image prune -f --filter "until=$(date --date '14 days ago' +'%Y-%m-%d')"
@unakatsuo
unakatsuo / raw_udp4.go
Last active July 23, 2024 12:55
Send UDP packet using Linux raw socket.
// +build linux
package main
import (
"fmt"
"net"
"os"
"syscall"
@unakatsuo
unakatsuo / jenkins-inotify.log
Created November 9, 2017 09:37
inotifywait patterns for Jenkins multiple branch jobs folder.
# New build started
/var/lib/jenkins/jobs/citest/branches/master/builds/ CREATE,ISDIR 28
# log modified
/var/lib/jenkins/jobs/citest/branches/master/builds/28/ MODIFY log
# The last log update
/var/lib/jenkins/jobs/citest/branches/master/builds/28/ CLOSE_WRITE,CLOSE log
# a build stage finished
@unakatsuo
unakatsuo / ts29061-access-request.sh
Created November 3, 2017 10:15
radclient 3GPP request examples
#!/bin/bash
set -e
cat <<EOF | radclient 192.168.56.150 auth testing123
User-Name="81901234567@apn1",
NAS-IP-Address=127.0.0.1,
NAS-Identifier="NAS1",
NAS-Port-Type=Virtual,
Service-Type=Framed-User,
@unakatsuo
unakatsuo / dropbox_poll.go
Created October 15, 2017 02:43
Dropbox ListFolderLongPoll example with no HTTP Authorization header
package dropbox
import (
"log"
"net/http"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/files"
)
@unakatsuo
unakatsuo / main.go
Created May 29, 2017 11:10
C.struct_in_addr
package main
// #include <arpa/inet.h>
import "C"
import (
"encoding/binary"
"fmt"
"net"
"unsafe"
)
@unakatsuo
unakatsuo / main.go
Created April 17, 2017 03:45
iovisor/bcc Go binding test
// +build: linux,cgo
package main
/*
#cgo pkg-config: libbcc
#include <bcc/bpf_common.h>
#include <bcc/libbpf.h>
*/
import "C"