CodeBlooded

joined 1 year ago
[–] CodeBlooded 2 points 3 weeks ago

This site is great for learning the foot notes to programming languages, including stuff like json, yaml, and hcl.

[–] CodeBlooded 31 points 3 months ago (2 children)

So, basically, “we started learning Git and accidentally blew away the only copy of the code base we had!” 😂

I’ve watched new developers delete 2 weeks worth of development by misunderstanding Git🤦‍♂️

[–] CodeBlooded 4 points 4 months ago (2 children)

Alright stranger, let’s hear it. What is it about Fish that you love so much?

I’ve been generally happy with bash or zsh, pretty much whatever is installed by default (and I honestly don’t know the difference between the two I just mentioned 😬).

[–] CodeBlooded 2 points 4 months ago

Gimp is all I know, I can’t compare to Photoshop, and I love it! ❤️

[–] CodeBlooded 1 points 4 months ago

That’s fair. The replies here have opened my narrow thoughts that I’ve had on everyone solely using UTC.

In my defense, when discussing this with others in person, I’ve only ever been given garbage reasons to have time zones…

Now …can we all agree to hate Daylight Saving Time?

[–] CodeBlooded 6 points 4 months ago

…this feels like Dune

[–] CodeBlooded 4 points 4 months ago

This sounds wonderful. I played Windows games on Linux for a decade, and it was often a painful experience. I’d love to see some real life in-game comparisons to illustrate what this brings to the table!

[–] CodeBlooded 1 points 4 months ago* (last edited 4 months ago) (2 children)

I don’t think it’s actually realistic that this would ever change at this point in the game. I do think we could have adapted to all using UTC if we never started with time zones in the first place.

[–] CodeBlooded -1 points 4 months ago

Yes. Many people already work shifts that have them do exactly that (show up to work on Monday, go home on Tuesday).

My first job had me work all sorts of shifts. Anything other than the day shift, I was showing up early or late evening one day, and leaving work early or late morning the next day.

[–] CodeBlooded 3 points 4 months ago (6 children)

Yes, this is literally what I’m proposing.

You do not still end up with the same issues. Somebody booking a ticket for a hotel room to be available at 1300 from a different time zone than said hotel will not arrive at the hotel to learn that the check in time is different from their expectation.

Regarding “the link between the hour of the day and the sun’s position,” I’m asserting that we should recalibrate this expectation based on time zones, rather than changing the clock to some fictitious time based on “noon” always equaling “1200.”

who gets to decide that everyone switches over and what is the new global time?

“Global time” in this context is already decided to be UTC. And no one gets to decide on the switch. This is a dream that will never come to fruition. 😕

[–] CodeBlooded 3 points 4 months ago (1 children)

Who gets to have the time-zone that’s noon at noon

I am asserting that we abandon this concept of “noon” having to be precisely when the pixels on the my clock take the form of “12:00”.

Who cares? Just let “noon” be whatever mid-day is where you live.

0 isn’t my midnight

Same thing, why does it matter? Why do people cling to this? Midnight should be when you are mid-way through the night, regardless of what time a clock shows.

It also doesn’t fix the “what time of day is it elsewhere in the world” problem, which still requires knowledge of time differences. You know. Time zones.

I don’t have time zones memorized, so I have to look up this information when I need to know it anyway. I did say in my post that the [time] “zones” would still exist if I had my way with UTC. I do still think it’s valuable to know the operating hours for different parts of the earth- I just think we can track this without having to have the madness that is time zones. However, while answering this, I do feel what you’re saying. Perhaps we do keep time zones, but only as a way to tell time that is secondary to UTC? (As compared to today, where UTC is often an afterthought, if people even think about it at all.)

 

Voyager, aka ‘wefwef.app’, just hit 1.0

This is a project that makes me really interested in what I can do with a PWA.

(It’s an Apollo-esque (an iOS app for Reddit) progressive web app for Lemmy, and it kicks ass so far.)

9
submitted 1 year ago* (last edited 1 year ago) by CodeBlooded to c/golang
 

I’ve been using this to execute Go “scripts” in CI pipelines where Bash just doesn’t cut it. It’s an interpreter for Go. It can be used to treat Go code like a “script,” rather than a compiled application. It is also able to be imported into a Go program and used to load up Go code dynamically at run time (think “loading plugins” with Go!).

From the readme:

release Build Status GoDoc

Yaegi is Another Elegant Go Interpreter. It powers executable Go scripts and plugins, in embedded interpreters or interactive shells, on top of the Go runtime.

Features

  • Complete support of Go specification
  • Written in pure Go, using only the standard library
  • Simple interpreter API: New(), Eval(), Use()
  • Works everywhere Go works
  • All Go & runtime resources accessible from script (with control)
  • Security: unsafe and syscall packages neither used nor exported by default
  • Support the latest 2 major releases of Go (Go 1.19 and Go 1.20)

Install

Go package

import "github.com/traefik/yaegi/interp"

Command-line executable

go install github.com/traefik/yaegi/cmd/yaegi@latest

Note that you can use rlwrap (install with your favorite package manager), and alias the yaegi command in alias yaegi='rlwrap yaegi' in your ~/.bashrc, to have history and command line edition.

CI Integration

curl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $GOPATH/bin v0.9.0

Usage

As an embedded interpreter

Create an interpreter with New(), run Go code with Eval():

package main

import (
	"github.com/traefik/yaegi/interp"
	"github.com/traefik/yaegi/stdlib"
)

func main() {
	i := interp.New(interp.Options{})

	i.Use(stdlib.Symbols)

	_, err := i.Eval(`import "fmt"`)
	if err != nil {
		panic(err)
	}

	_, err = i.Eval(`fmt.Println("Hello Yaegi")`)
	if err != nil {
		panic(err)
	}
}

Go Playground

As a dynamic extension framework

The following program is compiled ahead of time, except bar() which is interpreted, with the following steps:

  1. use of i.Eval(src) to evaluate the script in the context of interpreter
  2. use of v, err := i.Eval("foo.Bar") to get the symbol from the interpreter context, as a reflect.Value
  3. application of Interface() method and type assertion to convert v into bar, as if it was compiled
package main

import "github.com/traefik/yaegi/interp"

const src = `package foo
func Bar(s string) string { return s + "-Foo" }`

func main() {
	i := interp.New(interp.Options{})

	_, err := i.Eval(src)
	if err != nil {
		panic(err)
	}

	v, err := i.Eval("foo.Bar")
	if err != nil {
		panic(err)
	}

	bar := v.Interface().(func(string) string)

	r := bar("Kung")
	println(r)
}

Go Playground

As a command-line interpreter

The Yaegi command can run an interactive Read-Eval-Print-Loop:

$ yaegi
> 1 + 2
3
> import "fmt"
> fmt.Println("Hello World")
Hello World
>

Note that in interactive mode, all stdlib package are pre-imported, you can use them directly:

$ yaegi
> reflect.TypeOf(time.Date)
: func(int, time.Month, int, int, int, int, int, *time.Location) time.Time
>

Or interpret Go packages, directories or files, including itself:

$ yaegi -syscall -unsafe -unrestricted github.com/traefik/yaegi/cmd/yaegi
>

Or for Go scripting in the shebang line:

$ cat /tmp/test
#!/usr/bin/env yaegi
package main

import "fmt"

func main() {
	fmt.Println("test")
}
$ ls -la /tmp/test
-rwxr-xr-x 1 dow184 dow184 93 Jan  6 13:38 /tmp/test
$ /tmp/test
test

Documentation

Documentation about Yaegi commands and libraries can be found at usual godoc.org.

Limitations

Beside the known bugs which are supposed to be fixed in the short term, there are some limitations not planned to be addressed soon:

  • Assembly files (.s) are not supported.
  • Calling C code is not supported (no virtual "C" package).
  • Directives about the compiler, the linker, or embedding files are not supported.
  • Interfaces to be used from the pre-compiled code can not be added dynamically, as it is required to pre-compile interface wrappers.
  • Representation of types by reflect and printing values using %T may give different results between compiled mode and interpreted mode.
  • Interpreting computation intensive code is likely to remain significantly slower than in compiled mode.

Go modules are not supported yet. Until that, it is necessary to install the source into $GOPATH/src/github.com/traefik/yaegi to pass all the tests.

Contributing

Contributing guide.

License

Apache 2.0.

 

OrbStack is a fast, light, and simple way to run Docker containers and Linux machines on macOS. You can think of it as a supercharged WSL and Docker Desktop alternative, all in one easy-to-use app.

I just caught wind of this and have yet to try it. Does anyone here have any experience with OrbStack that they can speak to? 👀

view more: next ›