Readit News logoReadit News
seodisparate commented on C: Simple Defer, Ready to Use   gustedt.wordpress.com/202... · Posted by u/ingve
seodisparate · a year ago
One can use C's `cleanup` attribute like a defer. https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attribute...

The function signature is `void(MyType*)` if it is used like:

    __attribute__((cleanup(MyTypeCleanupFunction)))
    MyType myType;
If it's a pointer, it'll call the cleanup as a double ptr, and etc. Note that the specified cleanup function can do anything you want to, though the intended purpose is to cleanup the variable when it goes out of scope.

seodisparate commented on Git: The Stupid Password Store   tylercipriani.com/blog/20... · Posted by u/thcipriani
frizlab · 2 years ago
Or

    git remote set-url origin git@github.com:...
Or using URL replacements in git config.

seodisparate · 2 years ago
Or using .ssh/config since entries in there act like hostnames:

    # ~/.ssh/config
    Host github_ssh
        HostName github.com
        User git
        IdentityFile ~/.ssh/my_github_key

    > git remote add github github_ssh:Username/RepoName.git
This has worked reliably for me for quite a while now.

seodisparate commented on How to read C type declarations (2003)   unixwiz.net/techtips/read... · Posted by u/aragonite
seodisparate · 2 years ago
Reminds me of https://goshdarnfunctionpointers.com/ which has helped in some cases.
seodisparate commented on What Are File Descriptors in Linux   linuxtldr.com/file-descri... · Posted by u/marcodiego
shmerl · 2 years ago
> The lsof command is used to list the information about running processes in the system and can also be used to list the file descriptor under a specific PID.

> For that, use the “-d” flag to specify a range of file descriptors, with the “-p” option specifying the PID. To combine this selection, use the “-a” flag.

> $ lsof -a -d 0-2147483647 -p 11472

That works. A nicer way to do it:

htop > F3 (search by name to find the process) > Enter (to select) > L (open the list of file descriptors) > F4 (filter by resource name)

It lists all open files and other resources of the process.

seodisparate · 2 years ago
Isn't there `proc` on Linux systems?

Get the pid of the process you want to inspect, and while its running, execute `ls -lh /proc/<pid>/fd/`. It will list the open file descriptors for that process.

seodisparate commented on Committing Without Git   matheustavares.gitlab.io/... · Posted by u/matheust
seodisparate · 2 years ago
One could use `printf 'first\0second'` in the Bash shell as an example of making a "string" with null embedded into it, but you can't store that in a Bash variable.

    $ TEST_VAR="$(printf 'first\0second')"
    bash: warning: command substitution: ignored null byte in input
I'm not familiar with working with null characters in Bash in this way, but I think there might be a way to do it.

seodisparate commented on Building a Web Game in C   anguscheng.com/post/2023-... · Posted by u/4pkjai
seodisparate · 2 years ago
Similarly, I have a somewhat simple demo made for my website that is C++/Emscripten/Raylib. It's open source (MIT License) and you can grok the code here https://git.seodisparate.com/stephenseo/jumpartifact.com_dem... and check out the demo itself from the link within that page.
seodisparate commented on ROFL: An open-source license that promotes fun in coding   lmy.medium.com/rofl-an-op... · Posted by u/tslmy
seodisparate · 3 years ago
https://choosealicense.com/ is a good resource that lists a bunch of licenses explained.
seodisparate commented on Ditherpunk – The article I wish I had about monochrome image dithering (2021)   surma.dev/things/ditherpu... · Posted by u/samwillis
seodisparate · 3 years ago
I made a C++ project[1] (using OpenCL and blue noise) to generate dithered images/video for a course project (the course taught how to program for the GPU). If anyone wants to just jump straight into generating dithered images, you can try it out yourself. (It only works if OpenCL is configured for your system. It works on my desktop with a GPU and does not work on my laptop without a separate GPU.)

EDIT: Oh right, it also requires FFmpeg to be installed as it uses it. And libpng. And CMake. And PkgConfig.

[1]: https://github.com/Stephen-Seo/EN605.617.81.FA21_StephenSeo_...

seodisparate commented on How to Store an SSH Key on a Yubikey   xeiaso.net/blog/yubikey-s... · Posted by u/kadenwolff
seodisparate · 4 years ago
You can use a GPG key stored on a YubiKey with openssh, but with some caveats:

1. gpg-agent must act as your ssh-agent (which means ssh-agent should be disabled and replaced by gpg-agent).

2. If using `pinentry-curses` (YubiKey usually permits access to the contained GPG key via the use of a pin), you must have `export GPG_TTY=$(tty)` (or your shell's equivalent of setting the GPG_TTY environment value to the output of `tty`).

3. You can fetch the public key of your GPG key with `ssh-add -L` (gpg-agent must be acting as your ssh-agent, and the YubiKey with the GPG key has to be plugged in).

4. You must have the line `enable-ssh-support` in your `$GNUPGHOME/gpg-agent.conf`.

I used a guide[1] to set up a GPG key on to a YubiKey, and for those who don't want to use GPG, the guide also has a section[2] about just using an SSH key as well.

[1]: https://github.com/drduh/YubiKey-Guide

[2]: https://github.com/drduh/YubiKey-Guide#ssh

seodisparate commented on SELinux is unmanageable; just turn it off if it gets in your way   ctrl.blog/entry/selinux-u... · Posted by u/HyphenSam
kaba0 · 4 years ago
Convenience matter. Without it being automatically on everywhere, it doesn’t protect from much. Sure it can be good for the occasional random software you trust the least, but how many exploitable bugs were found in any of your completely trustable tools?

Also, afaik firejail runs as suid, making any possible escape much more serious.

seodisparate · 4 years ago
[1] discusses firejail running as root:

> For a server, the process exposed to the outside world runs as an unprivileged user (unbound or nobody). The process is started by a separate process running as root (as explained by @Ferroin above). The starting process is never exposed to outside.

> The same is true for Firejail. By the time the unprivileged server process starts, Firejail is already sleeping.

And I think Docker has a similar problem as mentioned in the "warning" section in [2]:

> Warning: Anyone added to the docker group is root equivalent because they can use the docker run --privileged command to start containers with root privileges. For more information see [3] and [4].

[1]: https://github.com/netblue30/firejail/issues/1720

[2]: https://wiki.archlinux.org/title/Docker#Installation

u/seodisparate

KarmaCake day106May 1, 2017
About
https://nexus.seodisparate.com

https://github.com/Stephen-Seo

View Original