Skip to content

Instantly share code, notes, and snippets.

View gdamore's full-sized avatar

Garrett D'Amore gdamore

View GitHub Profile
@gdamore
gdamore / unicode.d
Created September 17, 2022 16:44
unicode grapheme test
import std;
import std.utf;
import std.uni;
import std.range.primitives : walkLength;
import std.range : take, drop;
void main()
{
auto s2 = "\U0001f9db\u200d\u2640"; // this is a female vampire (vampire + ZWJ + female)
Loaded modules: [ scsi_vhci mac uppc neti ufs zfs apix uhci hook ip usba xhci specfs pcplusmp nfs cpu.generic arp sockfs smbsrv ]
kmdb: target stopped at:
kmdb_enter+0xb: movq %rax,%rdi
[0]> $C
fffffffffbc13e70 kmdb_enter+0xb()
fffffffffbc13ea0 debug_enter+0x55(fffffffff7806a12)
fffffffffbc13ed0 apix`apic_nmi_intr+0x5e(0, fffffffffbc13f10)
fffffffffbc13f00 av_dispatch_nmivect+0x2c(fffffffffbc13f10)
fffffffffbc13f10 nmiint+0x152()
fffffffffbc861b0 drv_usecwait+0x42(1)
@gdamore
gdamore / nngpubsub.c
Created November 7, 2018 04:10
nngpubsub perfdemo
// pub sub performance test -- adapted from pubsub demo in nanomsg,
// and updated for NNG.
//
// Copyright 2018 Garrett D'Amore <garrett@damore.org>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
--- a/src/protocol/bus0/bus.c
+++ b/src/protocol/bus0/bus.c
@@ -297,7 +297,12 @@ bus0_sock_getq_cb(void *arg)
}
nni_mtx_lock(&s->mtx);
- lastp = nni_list_last(&s->pipes);
+ if (((lastp = nni_list_last(&s->pipes)) != NULL) &&
+ (nni_pipe_id(lastp->npipe) == sender)) {
+ // If the last pipe in the list is our sender,
eventfd2(0, 0) = 5
write(5, "\1\0\0\0\0\0\0\0", 8) = 8
poll([{fd=5, events=POLLRDNORM}], 1, 100) = 0 (Timeout)
garrett@hipster{25}> git diff uts/common/os/exec.c | cat
diff --git a/usr/src/uts/common/os/exec.c b/usr/src/uts/common/os/exec.c
index f222a20..611a6f3 100644
--- a/usr/src/uts/common/os/exec.c
+++ b/usr/src/uts/common/os/exec.c
@@ -100,6 +100,7 @@ uint_t auxv_hwcap32_2 = 0; /* 32-bit version of auxv_hwcap2 */
#define PSUIDFLAGS (SNOCD|SUGID)
#define DEVFD "/dev/fd/"
+#define DEVFD_STRLEN (sizeof (DEVFD) - 1)
@gdamore
gdamore / nice .login
Created March 27, 2015 23:05
This is a handy .login for tcsh users -- gives a nicer login prompt, and updates the terminal window title bar.
set prompt="%B%m%b{%h}%# "
set echo_style=both
bindkey ' ' magic-space
if ( -f /usr/bin/stty ) then
stty sane
endif
switch ($term)
case "wterm":
case "xterm*":
@gdamore
gdamore / gist:08c731ff9e9e625b25f7
Created October 26, 2014 16:14
switch message cache to sync.Pool
diff --git a/message.go b/message.go
index 2ae59a5..e1321e8 100644
--- a/message.go
+++ b/message.go
@@ -15,6 +15,7 @@
package mangos
import (
+ "sync"
"sync/atomic"
diff --git a/usr/src/cmd/printf/printf.c b/usr/src/cmd/printf/printf.c
index fe1bb1b..bf07982 100644
--- a/usr/src/cmd/printf/printf.c
+++ b/usr/src/cmd/printf/printf.c
@@ -224,12 +224,19 @@ doformat(char *fmt, int *rval)
l = strspn(fmt, digits);
if ((l > 0) && (fmt[l] == '$')) {
int idx = atoi(fmt);
+ if (fargv == NULL) {
+ warnx1(_("incomplete use of n$"), NULL, NULL);
-tests[21][foramt]='%2$s'
-tests[21][args]='abc xyz"
+tests[21][format]='%2$s'
+tests[21][args]='abc xyz'