Skip to content

Instantly share code, notes, and snippets.

View smallnest's full-sized avatar

smallnest smallnest

View GitHub Profile
@smallnest
smallnest / sched.go
Created July 7, 2021 08:11 — forked from ipcjk/sched.go
golang syscall set real time priority for task
package main
import (
"fmt"
"syscall"
"unsafe"
)
const (
SCHED_NORMAL = iota
// Author : Sandesh Bhusal
// Date Feb 23, 2021
// You may copy, download and modify the source code according to your requirements :)
// Happy Spoofing!
// Original Code Lives at https://gist.github.com/sandeshbhusal/c8fa09546ffc076e5103456dd4e3742d
package main
import (
"flag"
@smallnest
smallnest / rawudp.go
Created May 28, 2021 03:22 — forked from chrisnc/rawudp.go
constructing ip/udp packets in go
package main
import (
"bufio"
"bytes"
"encoding/binary"
"flag"
"fmt"
"net"
"os"
@smallnest
smallnest / raw_udp4.go
Created April 29, 2021 03:59 — forked from unakatsuo/raw_udp4.go
Send UDP packet using Linux raw socket.
// +build linux
package main
import (
"fmt"
"net"
"os"
"syscall"
@smallnest
smallnest / scratch_server.go
Created April 23, 2021 02:05 — forked from jschaf/scratch_server.go
A Go web server from scratch using syscalls
package main
// Simple, single-threaded server using system calls instead of the net library.
//
// Omitted features from the go net package:
//
// - TLS
// - Most error checking
// - Only supports bodies that close, no persistent or chunked connections
// - Redirects
@smallnest
smallnest / benchmark_timers.go
Created January 14, 2021 10:09 — forked from draveness/benchmark_timers.go
Benchmark Golang Timers
package main
import (
"fmt"
"sort"
"sync"
"testing"
"time"
)
@smallnest
smallnest / LearnGoIn5mins.md
Created January 14, 2021 03:40 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
@smallnest
smallnest / piping.go
Created December 27, 2020 05:33 — forked from dagoof/piping.go
piping exec.Cmd in golang (example finds most recently modified file that is not directory or executable)
package main
import (
"os"
"exec"
)
func pipe_commands(commands ...*exec.Cmd) ([]byte, os.Error) {
for i, command := range commands[:len(commands) - 1] {
out, err := command.StdoutPipe()
if err != nil {
@smallnest
smallnest / main.go
Created December 25, 2020 07:43 — forked from Skarlso/main.go
Golang SSH connection with hostkey verification
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"golang.org/x/crypto/ssh"
kh "golang.org/x/crypto/ssh/knownhosts"
@smallnest
smallnest / sshclient.go
Created December 25, 2020 03:43 — forked from josephspurrier/sshclient.go
Golang SSH Client
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"