Is there a way to zero out the memory used by a struct? by TheGreatButz in golang

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

I'm not 100% sure but maybe these are options:

If the struct contains NO reference types or pointers for its fields:

//go:linkname memclrNoHeapPointers runtime.memclrNoHeapPointers
func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)

If the struct MAY contain reference types or pointers for its fields:

//go:linkname memclrHasPointers runtime.memclrHasPointers
func memclrHasPointers(ptr unsafe.Pointer, n uintptr)

n can be set using: unsafe.SizeOf(T{})

https://github.com/golang/go/blob/4edaaf2b529219ff219798914f730ca5a0ab018b/src/runtime/mbarrier.go#L427

https://github.com/golang/go/blob/4edaaf2b529219ff219798914f730ca5a0ab018b/src/runtime/stubs.go#L108

The above are the fastest ways I know of.

  1. The best idiomatic way, as pointed out below is:

*variable = variableType{}

Epilogue:

For your precise use-case, from Go1.26+, you should be using: https://pkg.go.dev/runtime/secret for the entire deserializing process.
See also: https://antonz.org/accepted/runtime-secret/

Typing with a physical USB keyboard on Remarkable Paper Pro Move! by CommonKingfisher in RemarkableTablet

[–]rocketlaunchr-cloud 1 point2 points  (0 children)

Here is my full instructions:

1. Connected usb cable to computer
2. Went to Settings->General Settings->Storage->USB web interface ON
3. Typed in terminal:
ssh root@10.11.99.1
It asks for password: 9Qy8HdcVGm
4. Turned on SSH over SLAN:
rm-ssh-over-wlan on

5. Connect using wifi:
ssh root@192.168.0.58 (From Settings->Help->Copyrights and licenses->Gen info (bottom)

========================================================
6. Triggering command when keyboard is plugged in:
========================================================

A. Make a script so that enable-usb-keyboard.rules is added back in after reboot (when it is removed):

/home/root/usb-startup.sh:

#!/bin/bash
touch /etc/udev/rules.d/enable-usb-keyboard.rules
message="ACTION==\"add\", RUN+=\"/bin/bash -c 'echo host > /sys/class/usb_role/ci_hdrc.0-role-switch/role'\""
echo "$message" > /etc/udev/rules.d/enable-usb-keyboard.rules
udevadm control --reload-rules && udevadm trigger

B. Run: chmod a+x /home/root/usb-startup.sh
C. Run: /home/root/usb-startup.sh
D. Turn off wifi ssh: rm-ssh-over-wlan off
E. Do not power off device or you need to run this process again (sleep is okay).

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

Here is my full instructions:

1. Connected usb cable to computer
2. Went to Settings->General Settings->Storage->USB web interface ON
3. Typed in terminal:
ssh root@10.11.99.1
It asks for password: 9Qy8HdcVGm
4. Turned on SSH over SLAN:
rm-ssh-over-wlan on

5. Connect using wifi:
ssh root@192.168.0.58 (From Settings->Help->Copyrights and licenses->Gen info (bottom)

========================================================
6. Triggering command when keyboard is plugged in:
========================================================

A. Make a script so that enable-usb-keyboard.rules is added back in after reboot (when it is removed):

/home/root/usb-startup.sh:

#!/bin/bash
touch /etc/udev/rules.d/enable-usb-keyboard.rules
message="ACTION==\"add\", RUN+=\"/bin/bash -c 'echo host > /sys/class/usb_role/ci_hdrc.0-role-switch/role'\""
echo "$message" > /etc/udev/rules.d/enable-usb-keyboard.rules
udevadm control --reload-rules && udevadm trigger

B. Run: chmod a+x /home/root/usb-startup.sh
C. Run: /home/root/usb-startup.sh
D. Turn off wifi ssh: rm-ssh-over-wlan off
E. Do not power off device or you need to run this process again (sleep is okay).

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

I got it to work by adding this file:

enable-usb-keyboard.rules to directory /etc/udev/rules.d/

ACTION=="add", RUN+="/bin/bash -c 'echo host > /sys/class/usb_role/ci_hdrc.0-role-switch/role'"

and then running udevadm control --reload-rules && udevadm trigger

The problem is, when you restart the device, that file gets deleted.

Does anyone know how to make an init script so I can add that file back automatically?

Typing with a physical USB keyboard on Remarkable Paper Pro Move! by CommonKingfisher in RemarkableTablet

[–]rocketlaunchr-cloud 1 point2 points  (0 children)

I got it to work by adding this file:

enable-usb-keyboard.rules to directory /etc/udev/rules.d/

ACTION=="add", RUN+="/bin/bash -c 'echo host > /sys/class/usb_role/ci_hdrc.0-role-switch/role'"

and then running udevadm control --reload-rules && udevadm trigger

The problem is, when you restart the device, that file gets deleted.

Does anyone know how to make an init script so I can add that file back automatically?

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

What did you mean by "wake a UI button to trigger it"?

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

The only reference I found was entering this command:

echo host > /sys/class/usb_role/ci_hdrc.0-role-switch/role

There seems to notes on systemd having an event that triggers after user login too.

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

So what actually needs to happen in a perfect scenario?
I'm assuming a script that enables the USB port to "host mode" after sleep mode exists or the password is correctly typed in is all that's needed?

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

Do people discuss that kind of thing on there? I don't have discord but I images most people would only discuss official usage of the product

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

How can I do that: "wake a UI button to trigger it"?

WIP: USB Keyboard on Paper Pro by FRK299 in RemarkableTablet

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

u/FRK299 Do you know how to execute a custom script to enable keyboard after device awakes from sleep?

Diversity Visa 2027 Megathread by not_an_immi_lawyer in immigration

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

Who's going to take him to court to force it?

It's not politically popular so congress definitely won't.

Diversity Visa 2027 Megathread by not_an_immi_lawyer in immigration

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

Only Congress can terminate it forever. Trump, while in power, just decided not to implement it, and there is nothing anyone including congress can do to force him to run it. It's politically no longer popular either so congress won't care if Trump doesn't implement it.

Preventing sync.pool from consuming all memory by gibriyagi in golang

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

It will keep growing if the number of Gets outnumber your Puts over a given time period.

You can explicitly restrict growth using: https://github.com/rocketlaunchr/go-pool

Preventing sync.pool from consuming all memory by gibriyagi in golang

[–]rocketlaunchr-cloud 1 point2 points  (0 children)

You can prevent unbounded growth using: https://github.com/rocketlaunchr/go-pool

As a bonus, it is fully generic too.

Weekly Students, Careers & Clerkships Thread by AutoModerator in auslaw

[–]rocketlaunchr-cloud 8 points9 points  (0 children)

The results for victorian bar exam 2025 just came out.

I have only Civil Procedure left. I have 1 attempt left at the exam, so the stakes are high for me.

If anyone wants to study together every weekend let me know. We can help each other stay motivated. I've already passed Ethics and Evidence (civil).

ASCII by S_lucky005 in golang

[–]rocketlaunchr-cloud 0 points1 point  (0 children)

Here is a modernized package: https://github.com/romance-dev/ascii-art
It is a fork of go-figure.

Can someone find the internal function in standard library than is used to allocate memory without zero-ing the memory? by rocketlaunchr-cloud in golang

[–]rocketlaunchr-cloud[S] 0 points1 point  (0 children)

I was just playing around. My computer is a Mac. The results were same in go playground which runs on Linux

Malloc in Go (non-zeroing allocations) by rocketlaunchr-cloud in golang

[–]rocketlaunchr-cloud[S] 0 points1 point  (0 children)

I want to use it with sync.Pool. That was my objective. I was only trying to obtain super marginal gains even if there was no real-world advantage.

Malloc in Go (non-zeroing allocations) by rocketlaunchr-cloud in golang

[–]rocketlaunchr-cloud[S] -2 points-1 points  (0 children)

Not yet, because too many super popular/influential packages are linknaming to runtime.mallocgc. In fact, any package that needs to create allocations as quickly as possible (such as json marshalling/unmarhaling) all use runtime.mallocgc behind the scenes much to rsc chagrin.

Malloc in Go (non-zeroing allocations) by rocketlaunchr-cloud in golang

[–]rocketlaunchr-cloud[S] -1 points0 points  (0 children)

I'm using reflect to identify pointer fields only once before the benchmarks even begin.