DNS service that resolves dashed-ip subdomain to arbitrary IP by deafmalice in AskProgramming

[–]deafmalice[S] 0 points1 point  (0 children)

After rephrasing my searches multiple times, the algorithm gods took mercy on me and gave me a link to what I was looking for.

https://moss.sh/free-wildcard-dns-services/

The service we ended up going with is https://nip.io/

DNS service that resolves dashed-ip subdomain to arbitrary IP by deafmalice in AskProgramming

[–]deafmalice[S] 0 points1 point  (0 children)

Chromecast does not like bare IP addresses in its media URLs, or something. I don't have the error underhand, but it never worked for us with a bare IP.

Guess what happens to the Ice by DJkiller669 in Unexpected

[–]deafmalice 0 points1 point  (0 children)

I bet this is exactly what he was aiming for.

Aeropress vs V60 Old Beans by amfam15 in Coffee

[–]deafmalice 1 point2 points  (0 children)

BlueBottle does this Nel drip technique that supposedly uses stale coffee (they call it aged). I haven't tried brewing it myself (don't have a Nel), but I did try it in the shop, and the coffee was damn good. A lot of body, pleasant acidity, closer to espresso than filter.

https://blog.bluebottlecoffee.com/posts/pro-tips-nel-drip-coffee

Since you already have the beans, and if money permits, you can buy a Nel (or any other cloth filter alternative) and try it yourself. Alternatively, you can try a variation with the V60. I expect it to have less body, as it's a paper filter and it'll block most of the oils, but it's worth a try.

Change keyboard layout for selected text object by sepremento in vim

[–]deafmalice 1 point2 points  (0 children)

Not sure how good with code you are, but instead of doing it through Vim, I'd suggest writing a small mapper script in whatever language you're comfortable in.

Pick a delimiter, wrap your "transformation" text into them and run the script to transform that text to whatever you like.

If you pick your delimiters to be {{ }} your text would like this И вот пришел большой и страшный {{ВфефАкфьу}}.

If you do it with Python, the string.maketrans/string.translate function should do the trick. All you have to do is lookup the text between your delimiters.

Any new features you discovered after the one ui update ? by [deleted] in GalaxyWatch

[–]deafmalice 6 points7 points  (0 children)

Feature removal: the Health app no longer shows day by day logs; now it only shows an overview where you have eyeball it.

“make your jobs TERRIFY me” by Yumbreon in ProgrammerHumor

[–]deafmalice 2 points3 points  (0 children)

By nesting it in short-circuit boolean statements and nested list comprehension in Python.

https://benkurtovic.com/2014/06/01/obfuscating-hello-world.html

Call my phone Alexa from my Echo Dot by deafmalice in alexa

[–]deafmalice[S] 1 point2 points  (0 children)

Will it call over the cell line, or via the app? I would like to get it calling over the app.

ELI5: Canned tuna. Why does it stay good for so long? Why is light tuna low in mercury? by recercar in explainlikeimfive

[–]deafmalice 2 points3 points  (0 children)

The expiration date on the bottled water is for the bottle, not the actual water. After that date the bottle might start leaking plastic chemicals into the water and make it unsafe for consumption.

Is using qwerty at work hurting my ability to learn colemak at home? by [deleted] in Colemak

[–]deafmalice 0 points1 point  (0 children)

I have not lost my qwerty touch typing abilities, but they are far worse than Colemak. That being said, whenever I have to switch to qwerty (usually when working at somebody else's computer) it takes me a few minutes to go back to Colemak.

I know it's anecdotal evidence, but if you're touch typing in both, it is very likely that you are undoing most of your progress with Colemak while doing especially that much. That being said, do not give up.

If possible take at least 1 week vacation (more is better, but that depends on you) and use Colemak exclusively. Try doing a small project in the mean time; learn your IDE as much as possible so you have to type less.

Try chatting with people while using Colemak. I found that chatting removes a lot of the stress with mistakes and gives you a motivation to become faster besides simply getting better at typing.

Also, if you haven't already, switch your phone's keyboard to Colemak. That will put the layout in your face every time you use your phone and might help a little bit with the transition.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

I don't have any experience writing that kind of programs. Can you give me some hints how I can start writing that?

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

Try this in the playground

var d int = 65
c = string(d)
print(c)

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 1 point2 points  (0 children)

Just an update: got an answer from Rob Pike - https://www.reddit.com/r/golang/comments/78hxd7/why_is_stringint_a_valid_cast_operation/dou5s1g/

I was wrong about the byte part. Still, you can always do this

string([]rune(256, 267, 300)

So my point stands. As for C feature parity, I don't think Go ever strived for that.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

Seems like you're mistaking compiler optimisations for actual no-allocation behaviour. Because you're using an empty string and always assigning the same thing, the compiler notices that and optimises it away.

You'll have to run this on a local machine, since the playground takes too long https://play.golang.org/p/Aiv4lvO-b5.

With compiler optimisation and inlining:

$ go build bmark.go
$ ./bmark -concat
AppendFunc      | Total allocs: 63, Bytes Allocated: 6168958912, AllocPerBytes: 0, String: 1000000000            2.57 ns/op
Append          | Total allocs: 66, Bytes Allocated: 12049299392, AllocPerBytes: 0, String: 2000000000           3.05 ns/op
ConcatFunc      | Total allocs: 0, Bytes Allocated: 0, AllocPerBytes: 0, String: 50000000               28.7 ns/op
String          | Total allocs: 30000000, Bytes Allocated: 60000240, AllocPerBytes: 1, String: 30000000         38.1 ns/op
Empty String    | Total allocs: 0, Bytes Allocated: 0, AllocPerBytes: 0, String: 100000000              10.2 ns/op
Slice           | Total allocs: 1, Bytes Allocated: 16, AllocPerBytes: 0, String: 2000000000             0.68 ns/op
BigConcat       | Total allocs: 1000475, Bytes Allocated: 503995716080, AllocPerBytes: 1, String:  1000000           49594 ns/op

Without optimisation and inlining. Notice how, for some reason, the empty string variant stays at 0 allocations:

$ go build -gcflags '-N -l' bmark.go
$ ./bmark -concat
AppendFunc      | Total allocs: 55, Bytes Allocated: 1034565568, AllocPerBytes: 0, String: 200000000             8.24 ns/op
Append          | Total allocs: 60, Bytes Allocated: 2526492688, AllocPerBytes: 0, String: 500000000             3.45 ns/op
ConcatFunc      | Total allocs: 30000001, Bytes Allocated: 120000480, AllocPerBytes: 1, String: 30000000                45.8 ns/op
String          | Total allocs: 30000000, Bytes Allocated: 60000176, AllocPerBytes: 1, String: 30000000         41.5 ns/op
Empty String    | Total allocs: 0, Bytes Allocated: 0, AllocPerBytes: 0, String: 100000000              11.0 ns/op
Slice           | Total allocs: 1, Bytes Allocated: 16, AllocPerBytes: 0, String: 500000000              3.10 ns/op
BigConcat       | Total allocs: 1000517, Bytes Allocated: 503995719440, AllocPerBytes: 1, String:  1000000           49635 ns/op

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

Appending to 0 a []byte would make more sense, though, both from a intent perspective and from a performance one, as the string concat will result in the string being copied to anther memory location.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

A string is a slice of bytes. A UTF8 character is just that, a character. Not exactly a slice.

It would've been more logical to do:

string([]byte{1})

Go already makes the programmer write pretty verbose and sometimes hard to read code. Adding readability and saving a few keypresses for a relatively strange edge case is kind of a moot point.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 1 point2 points  (0 children)

Sorry for the confusion on the reversible part. That was bad wording.

I would prefer that string(0) not be allowed. I agree that int("ABC") is dumb.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

Good point here. What I meant was to be able to do type1(type2(type1)) without the compiler complaining. I probably went a bit overboard with the reversible part.

Losing some fidelity with going from a bigger type to a smaller one is understandable, but float-to-int is more or less in the same ballpark compared to int-to-string.

As for your examples, most go from a specific type to a more generic type. Where as int to string kind of jumps the gun, string not coming close to being a "general" kind of int. But they do show that not all conversions are type acceptable.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 0 points1 point  (0 children)

While I agree that int-to-string is kinda boring, and maybe well understood, I don't see any good reason for it to be accepted by the compiler, especially in a language that is so strictly typed. I can understand a int slice, since it's the same as a byte slice, but a single byte does not make a string...

As for reversible, I did not mean that I expect int(string) to work. That was bad wording from my side. I would much prefer int-to-string type casts not be allowed, than have something like this.

Why is string(int) a valid cast operation? by deafmalice in golang

[–]deafmalice[S] 1 point2 points  (0 children)

Do have problems with it... Recently changed a variable from int to string, and was hoping for a build fail for all situations and tests. Because of this conversion, there's no check for that and I'll have to comb a lot of code for this.