Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Jakob Borg calmh

💭
I may be slow to respond.
Block or report user

Report or block calmh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@calmh
calmh / rwlisten.go
Last active Jun 12, 2018
Toy HTTP-over-stdio thing
View rwlisten.go
package main
import (
"fmt"
"io"
"net"
"net/http"
"os"
"time"
)
View gist:5ba12fdf06da21edac0d72f76f97081c
jb@unu:~/t/build $ VERBOSE=1 make
/usr/local/Cellar/cmake/3.8.2/bin/cmake -H/Users/jb/tmp/tray/subdirs/syncthingtray -B/Users/jb/tmp/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.8.2/bin/cmake -E cmake_progress_start /Users/jb/tmp/build/CMakeFiles /Users/jb/tmp/build/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f c++utilities/CMakeFiles/c++utilities.dir/build.make c++utilities/CMakeFiles/c++utilities.dir/depend
cd /Users/jb/tmp/build && /usr/local/Cellar/cmake/3.8.2/bin/cmake -E cmake_depends "Unix Makefiles" /Users/jb/tmp/tray/subdirs/syncthingtray /Users/jb/tmp/tray/c++utilities /Users/jb/tmp/build /Users/jb/tmp/build/c++utilities /Users/jb/tmp/build/c++utilities/CMakeFiles/c++utilities.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f c++utilities/CMakeFiles/c++utilities.dir/build.make c++utilities/CMakeFiles/c++u
View android.md

Starting from an Ubuntu installation or similar Docker image, install the NDK.

curl -s -o /tmp/android-ndk.zip https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
cd /usr/local
unzip /tmp/android-ndk.zip
rm -f /tmp/android-ndk.zip

Create the standalone stuff, whatever that is. Arm and arm64.

View flatten_test.go
package flatten
import (
"reflect"
"testing"
)
// This implements a flatten function for arbitrarily nested integer lists.
// I've chosen Go as the implementation language as it's the one I'm most
// comfortable in right now, but in a way this problem is a bad fit for the
View -
func TestTimeoutCond(t *testing.T) {
const (
// Low values to avoid being intrusive in continous testing. Can be
// increased significantly for stress testing.
iterations = 100
routines = 10
timeMult = 2
)
View main.go
package main
import "golang.org/x/time/rate"
func main() {
r := rate.NewLimiter(0, 100)
if r.Allow() {
panic("should not allow")
}
}
View -
jb@unu:~/s/g/c/j/timetest $ go run main.go
true
true
true
true
true
true
true
true
true
View sendhex.py
#!/usr/bin/env python
import sys
import socket
hex = ""
for line in sys.stdin.readlines():
first_space = line.index(' ')
if first_space > 2:
line = line[first_space:]
View sendhex.go
package main
import (
"bufio"
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"net"
View -
config/bgp_configs.go | 6 ++++
packet/bgp/bgp.go | 76 +++++++++++++++++++++++++++++++++++++++-----------
packet/bgp/bgp_test.go | 35 ++++++++++++++++++++++-
3 files changed, 99 insertions(+), 18 deletions(-)
diff --git a/config/bgp_configs.go b/config/bgp_configs.go
index 7125db4..c99342b 100644
--- a/config/bgp_configs.go
+++ b/config/bgp_configs.go
@@ -83,6 +83,7 @@ const (
You can’t perform that action at this time.